diff --git a/docs/driver.js.html b/docs/driver.js.html index c2142c3..00ee283 100644 --- a/docs/driver.js.html +++ b/docs/driver.js.html @@ -100,22 +100,6 @@ var d = { : str; }, - /** - * Sets the table prefix on the passed string - * - * @param {String} str - * @return {String} - * @private - */ - _prefix: function(str) { - if (str.startsWith(d.prefix)) - { - return str; - } - - return d.prefix + str; - }, - /** * Set the limit clause @@ -135,32 +119,6 @@ var d = { return sql; }, - /** - * Prefixes a table if it is not already prefixed - * - * @param {String} table - * @return {String} - */ - prefixTable: function(table) { - if (d.tablePrefix) - { - // Split identifier by period, will split into: - // database.schema.table OR - // schema.table OR - // database.table OR - // table - var idents = table.split('.', table); - var segments = idents.length; - - // Add the database prefix - idents[segments - 1] = d._prefix(idents[segments - 1]); - - table = idents.join('.'); - } - - return table; - }, - /** * Quote database table name, and set prefix * @@ -168,8 +126,6 @@ var d = { * @return {String} */ quoteTable: function(table) { - table = d.prefixTable(table); - // Quote after prefix return d.quoteIdentifiers(table); }, diff --git a/docs/helpers.js.html b/docs/helpers.js.html index 231d5b5..9ad6104 100644 --- a/docs/helpers.js.html +++ b/docs/helpers.js.html @@ -138,6 +138,11 @@ types.forEach(function (t) { * @return {Boolean} */ h['is' + t] = function (o) { + if (t.toLowerCase() === 'infinite') + { + t = 'infinity'; + } + return h.type(o) === t.toLowerCase(); }; }); diff --git a/docs/module-query-builder.html b/docs/module-query-builder.html index 3779a5f..227770c 100644 --- a/docs/module-query-builder.html +++ b/docs/module-query-builder.html @@ -955,7 +955,7 @@ @@ -1154,7 +1154,7 @@ @@ -1546,7 +1546,7 @@ diff --git a/docs/node-query.js.html b/docs/node-query.js.html index 24fe425..b72995c 100644 --- a/docs/node-query.js.html +++ b/docs/node-query.js.html @@ -104,7 +104,7 @@ nodeQuery.init = function (driverType, connObject, connLib) { } }); - return new qb(require(paths.driver), require(paths.adapter)(connObject)); + return qb(require(paths.driver), require(paths.adapter)(connObject)); }; diff --git a/docs/query-builder.js.html b/docs/query-builder.js.html index 47f4e8f..c020328 100644 --- a/docs/query-builder.js.html +++ b/docs/query-builder.js.html @@ -238,10 +238,6 @@ var QueryBuilder = function(driver, adapter) { { obj = args.$key; } - else - { - throw new Error("Invalid arguments passed"); - } Object.keys(obj).forEach(function(k) { // If a single value for the return @@ -267,8 +263,6 @@ var QueryBuilder = function(driver, adapter) { _p.mixedSet('whereValues', 'value', args.key, args.val); }, where: function(key, val, conj) { - conj = conj || 'AND'; - // Normalize key and value and insert into state.whereMap _p.whereMixedSet(key, val); @@ -300,6 +294,9 @@ var QueryBuilder = function(driver, adapter) { } _p.appendMap(conj, item, 'where'); + + // Clear the where Map + state.whereMap = {}; }); }, having: function(/*key, val, conj*/) { @@ -326,6 +323,9 @@ var QueryBuilder = function(driver, adapter) { string: item }); }); + + // Clear the where Map + state.whereMap = {}; }, whereIn: function(/*key, val, inClause, conj*/) { var args = getArgs('key:string, val:array, inClause:string, conj:string', arguments); @@ -382,7 +382,7 @@ var QueryBuilder = function(driver, adapter) { orderArray: [], groupArray: [], havingMap: [], - whereMap: [], + whereMap: {}, // Partials selectString: '', @@ -759,7 +759,7 @@ var QueryBuilder = function(driver, adapter) { * @return this */ this.groupStart = function() { - var conj = (state.queryMap.length < 1) ? ' WHERE ' : ' '; + var conj = (state.queryMap.length < 1) ? ' WHERE ' : ' AND '; _p.appendMap(conj, '(', 'groupStart'); return this; @@ -895,13 +895,14 @@ var QueryBuilder = function(driver, adapter) { * @param {Boolean} [reset=true] - Whether to reset the query builder so another query can be built * @return String */ - this.getCompiledSelect = function(table, reset) { - if (table) + this.getCompiledSelect = function(/*table, reset*/) { + var args = getArgs('[table]:string, [reset]:boolean', arguments); + if (args.table) { - this.from(table); + this.from(args.table); } - return _p.getCompile('get', table, reset); + return _p.getCompile('get', args.table, args.reset); }; /** diff --git a/package.json b/package.json index 751d0b1..09ce758 100755 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ci-node-query", - "version": "0.0.3", + "version": "0.0.4", "description": "A query builder for node based on the one in CodeIgniter", "author": "Timothy J Warren ", "engines": {