From da085f9e14d7df89375888de6f7621060a0ad2ff Mon Sep 17 00:00:00 2001 From: "Timothy J. Warren" Date: Mon, 1 Dec 2014 14:08:10 -0500 Subject: [PATCH] Make third init argument optional in some cases --- lib/node-query.js | 4 +++- lib/query-builder.js | 1 - package.json | 2 +- tests/adapters/mysql_test.js | 2 +- tests/adapters/pg_test.js | 2 +- 5 files changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/node-query.js b/lib/node-query.js index cd0e343..da9146f 100755 --- a/lib/node-query.js +++ b/lib/node-query.js @@ -11,10 +11,12 @@ var NodeQuery = function() { * @alias module:node-query * @param {String} drivername - 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 + * @param {String} [connLib] - The name of the db connection library you are using, eg. mysql or mysql2. Optional if the same as drivername * @return {queryBuilder} */ this.init = function (driverType, connObject, connLib) { + connLib = connLib || driverType; + var fs = require('fs'), qb = require('./query-builder'); diff --git a/lib/query-builder.js b/lib/query-builder.js index bd376c5..ffb7030 100755 --- a/lib/query-builder.js +++ b/lib/query-builder.js @@ -230,7 +230,6 @@ var QueryBuilder = function(driver, adapter) { }); }, whereNull: function(field, stmt, conj) { - conj = conj || 'AND'; field = driver.quoteIdentifiers(field); var item = field + ' ' + stmt; diff --git a/package.json b/package.json index 09d57eb..bc715d5 100755 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ci-node-query", - "version": "1.2.0", + "version": "1.2.1", "description": "A query builder for node based on the one in CodeIgniter", "author": "Timothy J Warren ", "engines": { diff --git a/tests/adapters/mysql_test.js b/tests/adapters/mysql_test.js index a7b95f9..4cd5e22 100644 --- a/tests/adapters/mysql_test.js +++ b/tests/adapters/mysql_test.js @@ -17,7 +17,7 @@ var connection = mysql.createConnection(config.conn); // Set up the query builder object var nodeQuery = require('../../lib/node-query'); -var qb = nodeQuery.init('mysql', connection, adapterName); +var qb = nodeQuery.init('mysql', connection); // Set up the test base testBase._setUp(qb, function(test, err, rows) { diff --git a/tests/adapters/pg_test.js b/tests/adapters/pg_test.js index 2ca267f..a817993 100644 --- a/tests/adapters/pg_test.js +++ b/tests/adapters/pg_test.js @@ -22,7 +22,7 @@ connection.connect(function(err) { // Set up the query builder object var nodeQuery = require('../../lib/node-query'); -var qb = nodeQuery.init('pg', connection, adapterName); +var qb = nodeQuery.init('pg', connection); // Set up the test base