Fix mysql insert batch tests
This commit is contained in:
parent
763a29d733
commit
383d632bb0
@ -89,7 +89,7 @@ gulp.task('sloc', () => gulp.src(SRC_FILES).pipe(sloc()));
|
|||||||
gulp.task('test-sloc', () => gulp.src(TEST_FILES).pipe(sloc()));
|
gulp.task('test-sloc', () => gulp.src(TEST_FILES).pipe(sloc()));
|
||||||
|
|
||||||
gulp.task('docs', () => {
|
gulp.task('docs', () => {
|
||||||
gulp.src(['lib/**/*.js'])
|
gulp.src(['lib/*.js'])
|
||||||
.pipe(documentation({format: 'html'}))
|
.pipe(documentation({format: 'html'}))
|
||||||
.pipe(gulp.dest('docs'));
|
.pipe(gulp.dest('docs'));
|
||||||
gulp.src(['lib/*.js'])
|
gulp.src(['lib/*.js'])
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
let helpers = require('./helpers');
|
const XRegExp = require('xregexp');
|
||||||
|
const helpers = require('./helpers');
|
||||||
|
|
||||||
// --------------------------------------------------------------------------
|
// --------------------------------------------------------------------------
|
||||||
|
|
||||||
@ -20,7 +21,7 @@ class QueryParser {
|
|||||||
constructor(driver) {
|
constructor(driver) {
|
||||||
this.driver = driver;
|
this.driver = driver;
|
||||||
|
|
||||||
let matchPatterns = {
|
const matchPatterns = {
|
||||||
function: /([a-z0-9_]+\((.*)\))/i,
|
function: /([a-z0-9_]+\((.*)\))/i,
|
||||||
operator: /\!=?|\=|\+|&&?|~|\|\|?|\^|\/|<>|>=?|<=?|\-|%|OR|AND|NOT|XOR/ig,
|
operator: /\!=?|\=|\+|&&?|~|\|\|?|\^|\/|<>|>=?|<=?|\-|%|OR|AND|NOT|XOR/ig,
|
||||||
literal: /([0-9]+)|'(.*?)'|true|false/ig,
|
literal: /([0-9]+)|'(.*?)'|true|false/ig,
|
||||||
@ -28,21 +29,21 @@ class QueryParser {
|
|||||||
|
|
||||||
// Full pattern for identifiers
|
// Full pattern for identifiers
|
||||||
// Making sure that literals and functions aren't matched
|
// Making sure that literals and functions aren't matched
|
||||||
matchPatterns.identifier = new RegExp(
|
matchPatterns.identifier = XRegExp(
|
||||||
'('
|
`(
|
||||||
+ '(?!'
|
(?!
|
||||||
+ matchPatterns['function'].source + '|'
|
${matchPatterns['function'].source}|
|
||||||
+ matchPatterns.literal.source
|
${matchPatterns.literal.source}
|
||||||
+ ')'
|
)
|
||||||
+ '([a-z_\-]+[0-9]*\\.?)'
|
([a-z_\-]+[0-9]*\\.?)
|
||||||
+ ')+', 'ig');
|
)+`, 'igx');
|
||||||
|
|
||||||
// Full pattern for determining ordering of the pieces
|
// Full pattern for determining ordering of the pieces
|
||||||
matchPatterns.joinCombined = new RegExp(
|
matchPatterns.joinCombined = XRegExp(
|
||||||
matchPatterns['function'].source + '+|'
|
`${matchPatterns['function'].source}+| # functions
|
||||||
+ matchPatterns.literal.source + '+|'
|
${matchPatterns.literal.source}+| # literal values
|
||||||
+ matchPatterns.identifier.source
|
${matchPatterns.identifier.source} # identifiers
|
||||||
+ '|(' + matchPatterns.operator.source + ')+', 'ig');
|
|(${matchPatterns.operator.source})+`, 'igx');
|
||||||
|
|
||||||
this.matchPatterns = matchPatterns;
|
this.matchPatterns = matchPatterns;
|
||||||
this.identifierBlacklist = ['true', 'false', 'null'];
|
this.identifierBlacklist = ['true', 'false', 'null'];
|
||||||
|
@ -22,28 +22,6 @@ module.exports = function mysqlBase(qb, nodeQuery, expect, testRunner, promiseTe
|
|||||||
return done();
|
return done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
test('Test Insert Batch', done => {
|
|
||||||
let data = [
|
|
||||||
{
|
|
||||||
id: 544,
|
|
||||||
key: 3,
|
|
||||||
val: new Buffer('7'),
|
|
||||||
}, {
|
|
||||||
id: 89,
|
|
||||||
key: 34,
|
|
||||||
val: new Buffer('10 o\'clock'),
|
|
||||||
}, {
|
|
||||||
id: 48,
|
|
||||||
key: 403,
|
|
||||||
val: new Buffer('97'),
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
qb.insertBatch('create_test', data, (err, rows) => {
|
|
||||||
expect(err).is.not.ok;
|
|
||||||
return done();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------
|
/*---------------------------------------------------------------------------
|
||||||
Promise Tests
|
Promise Tests
|
||||||
|
@ -26,4 +26,27 @@ let qb = nodeQuery.init('mysql', connection, adapterName);
|
|||||||
|
|
||||||
suite('Mysql2 adapter tests -', () => {
|
suite('Mysql2 adapter tests -', () => {
|
||||||
require('./mysql-base')(qb, nodeQuery, expect, testRunner, promiseTestRunner);
|
require('./mysql-base')(qb, nodeQuery, expect, testRunner, promiseTestRunner);
|
||||||
|
|
||||||
|
test('Test Insert Batch', done => {
|
||||||
|
let data = [
|
||||||
|
{
|
||||||
|
id: 5441,
|
||||||
|
key: 3,
|
||||||
|
val: new Buffer('7'),
|
||||||
|
}, {
|
||||||
|
id: 891,
|
||||||
|
key: 34,
|
||||||
|
val: new Buffer('10 o\'clock'),
|
||||||
|
}, {
|
||||||
|
id: 481,
|
||||||
|
key: 403,
|
||||||
|
val: new Buffer('97'),
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
qb.insertBatch('create_test', data, (err, rows) => {
|
||||||
|
expect(err).is.not.ok;
|
||||||
|
return done();
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
@ -26,4 +26,27 @@ let qb = nodeQuery.init('mysql', connection);
|
|||||||
|
|
||||||
suite('Mysql adapter tests -', () => {
|
suite('Mysql adapter tests -', () => {
|
||||||
require('./mysql-base')(qb, nodeQuery, expect, testRunner, promiseTestRunner);
|
require('./mysql-base')(qb, nodeQuery, expect, testRunner, promiseTestRunner);
|
||||||
|
|
||||||
|
test('Test Insert Batch', done => {
|
||||||
|
let data = [
|
||||||
|
{
|
||||||
|
id: 544,
|
||||||
|
key: 3,
|
||||||
|
val: new Buffer('7'),
|
||||||
|
}, {
|
||||||
|
id: 89,
|
||||||
|
key: 34,
|
||||||
|
val: new Buffer('10 o\'clock'),
|
||||||
|
}, {
|
||||||
|
id: 48,
|
||||||
|
key: 403,
|
||||||
|
val: new Buffer('97'),
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
qb.insertBatch('create_test', data, (err, rows) => {
|
||||||
|
expect(err).is.not.ok;
|
||||||
|
return done();
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
@ -1,7 +1,7 @@
|
|||||||
--ui tdd
|
--ui tdd
|
||||||
--bail
|
--bail
|
||||||
--recursive
|
--recursive
|
||||||
--reporter list
|
--reporter nyan
|
||||||
--slow 200
|
--slow 200
|
||||||
--timeout 10000
|
--timeout 10000
|
||||||
--check-leaks
|
--check-leaks
|
||||||
|
Loading…
Reference in New Issue
Block a user