Fix some code-style issues and fix jenkins build

This commit is contained in:
Timothy Warren 2016-03-09 15:05:38 -05:00
parent 7afb44dc20
commit 7f982a4c2b
14 changed files with 82 additions and 65 deletions

6
API.md
View File

@ -15,8 +15,10 @@ Create a query builder object
**Parameters**
- `driverType` **String** The name of the database type, eg. mysql or pg
- `connObject` **Object** A connection object from the database library you are connecting with
- `connLib` **[String]** The name of the db connection library you are using, eg. mysql or mysql2. Optional if the same as driverType
- `connObject` **Object** A connection object from the database library
you are connecting with
- `connLib` **[String]** The name of the db connection library you are
using, eg. mysql or mysql2. Optional if the same as driverType
Returns **QueryBuilder** The Query Builder object

View File

@ -2,7 +2,7 @@
## 3.2.0
* Added public `query` method for making arbitrary sql calls
* Added back tests for `node-query` adapter. Using this adapter with promises is not currently supported.
* Added back tests for `node-firebird` adapter. Using this adapter with promises is not currently supported.
## 3.1.0
* Added support for promises on query execution methods

View File

@ -305,14 +305,16 @@
<li><code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a></code> <strong>connObject</strong>
:
<div class='force-inline'>
<p>A connection object from the database library you are connecting with</p>
<p>A connection object from the database library
you are connecting with</p>
</div>
</li>
<li><code>[<code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">String</a></code>]</code> <strong>connLib</strong>
:
<div class='force-inline'>
<p>The name of the db connection library you are using, eg. mysql or mysql2. Optional if the same as driverType</p>
<p>The name of the db connection library you are
using, eg. mysql or mysql2. Optional if the same as driverType</p>
</div>
</li>

View File

@ -21,7 +21,9 @@ let Driver = {
* @private
*/
_quote(str) {
return (helpers.isString(str) && ! (str.startsWith(Driver.identifierStartChar) || str.endsWith(Driver.identifierEndChar)))
return (helpers.isString(str)
&& ! (str.startsWith(Driver.identifierStartChar) || str.endsWith(Driver.identifierEndChar))
)
? `${Driver.identifierStartChar}${str}${Driver.identifierEndChar}`
: str;
},

View File

@ -23,8 +23,10 @@ class NodeQuery {
* Create a query builder object
*
* @param {String} driverType - The name of the database type, eg. mysql or pg
* @param {Object} connObject - A connection object from the database library you are connecting with
* @param {String} [connLib] - The name of the db connection library you are using, eg. mysql or mysql2. Optional if the same as driverType
* @param {Object} connObject - A connection object from the database library
* you are connecting with
* @param {String} [connLib] - The name of the db connection library you are
* using, eg. mysql or mysql2. Optional if the same as driverType
* @return {QueryBuilder} - The Query Builder object
*/
init(driverType, connObject, connLib) {

View File

@ -131,7 +131,8 @@ class QueryBuilderBase {
* @return {Array} - modified state array
*/
_mixedSet(/* $letName, $valType, $key, [$val] */) {
let args = getArgs('$letName:string, $valType:string, $key:object|string|number, [$val]', arguments);
const argPattern = '$letName:string, $valType:string, $key:object|string|number, [$val]';
let args = getArgs(argPattern, arguments);
let obj = {};
@ -784,7 +785,8 @@ class QueryBuilder extends QueryBuilderBase {
* @return {void|Promise} - If no callback is passed, a promise is returned
*/
get(/* [table], [limit], [offset], [callback] */) {
let args = getArgs('[table]:string, [limit]:number, [offset]:number, [callback]:function', arguments);
const argPattern = '[table]:string, [limit]:number, [offset]:number, [callback]:function';
let args = getArgs(argPattern, arguments);
if (args.table) {
this.from(args.table);

View File

@ -127,7 +127,8 @@ types.forEach(t => {
* Determine whether a variable is of the type specified in the
* function name, eg isNumber
*
* Types available are Null, Undefined, Object, Array, String, Number, Boolean, Function, RegExp, NaN and Infinite
* Types available are Null, Undefined, Object, Array, String, Number,
* Boolean, Function, RegExp, NaN and Infinite
*
* @private
* @param {mixed} o - The object to check its type

View File

@ -1,6 +1,6 @@
'use strict';
const configFile = (process.env.CI) ? '../config-travis.json' : '../config.json';
const configFile = (process.env.TRAVIS) ? '../config-travis.json' : '../config.json';
// Load the test base
const reload = require('require-reload')(require);

View File

@ -1,6 +1,6 @@
'use strict';
const configFile = (process.env.CI) ? '../config-travis.json' : '../config.json';
const configFile = (process.env.TRAVIS) ? '../config-travis.json' : '../config.json';
// Load the test base
const reload = require('require-reload')(require);

View File

@ -1,31 +1,32 @@
'use strict';
// Load the test base
const path = require('path');
const reload = require('require-reload')(require);
const testBase = reload('../base');
const promisify = require('../../lib/promisify');
const expect = reload('chai').expect;
const testRunner = testBase.testRunner;
const promiseTestRunner = testBase.promiseTestRunner;
(() => {
// Load the test base
const path = require('path');
const reload = require('require-reload')(require);
const testBase = reload('../base');
const promisify = require('../../lib/promisify');
const expect = reload('chai').expect;
const testRunner = testBase.testRunner;
const promiseTestRunner = testBase.promiseTestRunner;
// Load the test config file
let adapterName = 'node-firebird';
let Firebird = reload(adapterName);
const config = reload('../config.json')[adapterName];
config.conn.database = path.join(__dirname, config.conn.database);
let nodeQuery = reload('../../lib/NodeQuery');
// Load the test config file
let adapterName = 'node-firebird';
let Firebird = reload(adapterName);
const config = reload('../config.json')[adapterName];
config.conn.database = path.join(__dirname, config.conn.database);
let nodeQuery = reload('../../lib/NodeQuery');
let qb = null;
let qb = null;
// Skip on TravisCi
if (process.env.CI || process.env.JENKINS_HOME) {
// Skip on TravisCi
if (process.env.CI) {
return;
}
}
// Promisifying the connection seems to be the only way to get
// this test suite to run consistently.
promisify(Firebird.attach)(config.conn).then(db => {
// Promisifying the connection seems to be the only way to get
// this test suite to run consistently.
promisify(Firebird.attach)(config.conn).then(db => {
qb = nodeQuery.init('firebird', db, adapterName);
suite('Firebird adapter tests -', () => {
test('nodeQuery.getQuery = nodeQuery.init', () => {
@ -35,7 +36,7 @@ promisify(Firebird.attach)(config.conn).then(db => {
test('insertBatch throws error', () => {
expect(() => {
qb.driver.insertBatch('create_test', []);
}).to.throw(Error, "Not Implemented");
}).to.throw(Error, 'Not Implemented');
});
/*---------------------------------------------------------------------------
Callback Tests
@ -54,6 +55,7 @@ promisify(Firebird.attach)(config.conn).then(db => {
qb.end();
});
});
}).catch(err => {
}).catch(err => {
throw new Error(err);
});
});
})();

View File

@ -1,5 +1,6 @@
'use strict';
// jscs:disable
// Load the test base
const chai = require('chai');
const chaiAsPromised = require('chai-as-promised');

View File

@ -1,5 +1,6 @@
'use strict';
// jscs:disable
// Load the test base
const chai = require('chai');
const chaiAsPromised = require('chai-as-promised');

View File

@ -1,5 +1,6 @@
'use strict';
// jscs:disable
module.exports = {
'Get tests -': {
'Get with function': {

View File

@ -15,7 +15,8 @@ let State = require('../lib/State');
let state = new State();
let mixedSet = function mixedSet(/* $letName, $valType, $key, [$val] */) {
let args = getArgs('$letName:string, $valType:string, $key:object|string|number, [$val]', arguments);
const argPattern = '$letName:string, $valType:string, $key:object|string|number, [$val]';
let args = getArgs(argPattern, arguments);
let obj = {};