diff --git a/docs/adapter.js.html b/docs/adapter.js.html
index 756b7c4..ef7945a 100644
--- a/docs/adapter.js.html
+++ b/docs/adapter.js.html
@@ -110,7 +110,7 @@ module.exports = {
Documentation generated by JSDoc 3.3.0-alpha9
- on Wed Nov 5th 2014 using the DocStrap template.
diff --git a/docs/driver.js.html b/docs/driver.js.html
index daa3b05..5a9e47b 100644
--- a/docs/driver.js.html
+++ b/docs/driver.js.html
@@ -252,7 +252,7 @@ module.exports = d;
Documentation generated by JSDoc 3.3.0-alpha9
- on Wed Nov 5th 2014 using the DocStrap template.
diff --git a/docs/helpers.js.html b/docs/helpers.js.html
index caf43be..4f7f753 100644
--- a/docs/helpers.js.html
+++ b/docs/helpers.js.html
@@ -161,12 +161,6 @@ var h = {
for(i=0; i< l; i++)
{
- // Recurse for nested arrays
- if (Array.isArray(arr[i]))
- {
- return h.regexInArray(arr[i], pattern);
- }
-
// Short circuit if any items match
if (pattern.test(arr[i])) return true;
}
@@ -219,7 +213,7 @@ module.exports = h;
Documentation generated by JSDoc 3.3.0-alpha9
- on Wed Nov 5th 2014 using the DocStrap template.
diff --git a/docs/index.html b/docs/index.html
index 6099f99..d4cea68 100644
--- a/docs/index.html
+++ b/docs/index.html
@@ -148,7 +148,7 @@ query.select('foo')
Documentation generated by JSDoc 3.3.0-alpha9
- on Wed Nov 5th 2014 using the DocStrap template.
diff --git a/docs/module-adapter.html b/docs/module-adapter.html
index 08b6b03..e1896bb 100644
--- a/docs/module-adapter.html
+++ b/docs/module-adapter.html
@@ -354,7 +354,7 @@
Documentation generated by JSDoc 3.3.0-alpha9
- on Wed Nov 5th 2014 using the DocStrap template.
diff --git a/docs/module-driver.html b/docs/module-driver.html
index efcb4bf..f75afe5 100644
--- a/docs/module-driver.html
+++ b/docs/module-driver.html
@@ -170,7 +170,7 @@
Documentation generated by JSDoc 3.3.0-alpha9
- on Wed Nov 5th 2014 using the DocStrap template.
diff --git a/docs/module-helpers.html b/docs/module-helpers.html
index 9f822c3..c5cd3d4 100644
--- a/docs/module-helpers.html
+++ b/docs/module-helpers.html
@@ -190,7 +190,7 @@ function name, eg isNumber
@@ -1027,7 +1027,7 @@ in the passed array
Documentation generated by JSDoc 3.3.0-alpha9
- on Wed Nov 5th 2014 using the DocStrap template.
diff --git a/docs/module-node-query.html b/docs/module-node-query.html
index 68a30e5..a999e77 100644
--- a/docs/module-node-query.html
+++ b/docs/module-node-query.html
@@ -457,7 +457,7 @@
Documentation generated by JSDoc 3.3.0-alpha9
- on Wed Nov 5th 2014 using the DocStrap template.
diff --git a/docs/module-query-builder.html b/docs/module-query-builder.html
index 2721e0c..f491edf 100644
--- a/docs/module-query-builder.html
+++ b/docs/module-query-builder.html
@@ -383,7 +383,7 @@
@@ -519,7 +519,7 @@
@@ -764,7 +764,7 @@
@@ -955,7 +955,7 @@
@@ -1154,7 +1154,7 @@
@@ -1355,7 +1355,7 @@
@@ -1546,7 +1546,7 @@
@@ -1641,7 +1641,7 @@
@@ -1788,7 +1788,7 @@
@@ -1875,7 +1875,7 @@
@@ -1962,7 +1962,7 @@
@@ -2147,7 +2147,7 @@
@@ -2357,7 +2357,7 @@
@@ -2539,7 +2539,7 @@
@@ -2771,7 +2771,7 @@
@@ -2997,7 +2997,7 @@
@@ -3176,7 +3176,7 @@
@@ -3402,7 +3402,7 @@
@@ -3593,7 +3593,7 @@
@@ -3681,7 +3681,7 @@ prefixed with 'OR'
@@ -3866,7 +3866,7 @@ prefixed with 'OR'
@@ -4092,7 +4092,7 @@ prefixed with 'OR'
@@ -4180,7 +4180,7 @@ prefixed with 'OR NOT'
@@ -4406,7 +4406,7 @@ prefixed with 'OR NOT'
@@ -4591,7 +4591,7 @@ prefixed with 'OR NOT'
@@ -4750,7 +4750,279 @@ prefixed with 'OR NOT'
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Returns:
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ orWhereIsNotNull(field)
+
+
+
+
+
+
+
+
Field is not null prefixed with 'OR'
+
+
+
+
+
+
+
+
+ Parameters:
+
+
+
+
+
+
+ Name |
+
+
+ Type |
+
+
+
+
+
+ Description |
+
+
+
+
+
+
+
+
+ field |
+
+
+
+
+
+String
+
+
+
+ |
+
+
+
+
+
+ |
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ - Source:
+ -
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Returns:
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ orWhereIsNull(field)
+
+
+
+
+
+
+
+
Field is null prefixed with 'OR'
+
+
+
+
+
+
+
+
+ Parameters:
+
+
+
+
+
+
+ Name |
+
+
+ Type |
+
+
+
+
+
+ Description |
+
+
+
+
+
+
+
+
+ field |
+
+
+
+
+
+String
+
+
+
+ |
+
+
+
+
+
+ |
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ - Source:
+ -
+
@@ -4909,7 +5181,7 @@ prefixed with 'OR NOT'
@@ -5048,7 +5320,7 @@ prefixed with 'OR NOT'
@@ -5230,7 +5502,7 @@ prefixed with 'OR NOT'
@@ -5440,7 +5712,7 @@ prefixed with 'OR NOT'
@@ -5625,7 +5897,7 @@ prefixed with 'OR NOT'
@@ -5784,7 +6056,279 @@ prefixed with 'OR NOT'
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Returns:
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ whereIsNotNull(field)
+
+
+
+
+
+
+
+
Specify that a field IS NOT NULL
+
+
+
+
+
+
+
+
+ Parameters:
+
+
+
+
+
+
+ Name |
+
+
+ Type |
+
+
+
+
+
+ Description |
+
+
+
+
+
+
+
+
+ field |
+
+
+
+
+
+String
+
+
+
+ |
+
+
+
+
+
+ |
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ - Source:
+ -
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Returns:
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ whereIsNull(field)
+
+
+
+
+
+
+
+
Select a field that is Null
+
+
+
+
+
+
+
+
+ Parameters:
+
+
+
+
+
+
+ Name |
+
+
+ Type |
+
+
+
+
+
+ Description |
+
+
+
+
+
+
+
+
+ field |
+
+
+
+
+
+String
+
+
+
+ |
+
+
+
+
+
+ The name of the field that has a NULL value |
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ - Source:
+ -
+
@@ -5943,7 +6487,7 @@ prefixed with 'OR NOT'
@@ -6007,7 +6551,7 @@ prefixed with 'OR NOT'
Documentation generated by JSDoc 3.3.0-alpha9
- on Wed Nov 5th 2014 using the DocStrap template.
diff --git a/docs/module-query-parser.html b/docs/module-query-parser.html
index a18b9f6..1870029 100644
--- a/docs/module-query-parser.html
+++ b/docs/module-query-parser.html
@@ -466,7 +466,7 @@
Documentation generated by JSDoc 3.3.0-alpha9
- on Wed Nov 5th 2014 using the DocStrap template.
diff --git a/docs/modules.list.html b/docs/modules.list.html
index 409d48a..a4ed007 100644
--- a/docs/modules.list.html
+++ b/docs/modules.list.html
@@ -158,7 +158,7 @@
Documentation generated by JSDoc 3.3.0-alpha9
- on Wed Nov 5th 2014 using the DocStrap template.
diff --git a/docs/node-query.js.html b/docs/node-query.js.html
index c7aafe3..dd6f63b 100644
--- a/docs/node-query.js.html
+++ b/docs/node-query.js.html
@@ -149,7 +149,7 @@ module.exports = new NodeQuery();
Documentation generated by JSDoc 3.3.0-alpha9
- on Wed Nov 5th 2014 using the DocStrap template.
diff --git a/docs/query-builder.js.html b/docs/query-builder.js.html
index 1f46b3c..0888f51 100644
--- a/docs/query-builder.js.html
+++ b/docs/query-builder.js.html
@@ -262,6 +262,25 @@ var QueryBuilder = function(driver, adapter) {
_p.mixedSet('whereMap', 'both', args.key, args.val);
_p.mixedSet('whereValues', 'value', args.key, args.val);
},
+ fixConjunction: function(conj) {
+ var lastItem = state.queryMap[state.queryMap.length - 1];
+ var conjunctionList = helpers.arrayPluck(state.queryMap, 'conjunction');
+
+ if (state.queryMap.length === 0 || ( ! helpers.regexInArray(conjunctionList, /^ ?WHERE/i)))
+ {
+ conj = " WHERE ";
+ }
+ else if (lastItem.type === 'groupStart')
+ {
+ conj = '';
+ }
+ else
+ {
+ conj = ' ' + conj + ' ';
+ }
+
+ return conj;
+ },
where: function(key, val, defaultConj) {
// Normalize key and value and insert into state.whereMap
_p.whereMixedSet(key, val);
@@ -276,24 +295,8 @@ var QueryBuilder = function(driver, adapter) {
// Simple key value, or an operator?
item += (fieldArray.length === 1 || fieldArray[1] === '') ? '=?' : " " + fieldArray[1] + " ?";
- var firstItem = state.queryMap[0],
- lastItem = state.queryMap[state.queryMap.length - 1];
-
// Determine the correct conjunction
- var conjunctionList = helpers.arrayPluck(state.queryMap, 'conjunction');
- var conj = defaultConj;
- if (state.queryMap.length === 0 || ( ! helpers.regexInArray(conjunctionList, /^ ?WHERE/i)))
- {
- conj = " WHERE ";
- }
- else if (lastItem.type === 'groupStart')
- {
- conj = '';
- }
- else
- {
- conj = ' ' + conj + ' ';
- }
+ var conj = _p.fixConjunction(defaultConj);
_p.appendMap(conj, item, 'where');
@@ -301,6 +304,13 @@ var QueryBuilder = function(driver, adapter) {
state.whereMap = {};
});
},
+ whereNull: function(field, stmt, conj) {
+ conj = conj || 'AND';
+ field = driver.quoteIdentifiers(field);
+ var item = field + ' ' + stmt;
+
+ _p.appendMap(_p.fixConjunction(conj), item, 'whereNull');
+ },
having: function(/*key, val, conj*/) {
var args = getArgs('key:string|object, [val]:string|number, [conj]:string', arguments);
args.conj = args.conj || 'AND';
@@ -596,6 +606,50 @@ var QueryBuilder = function(driver, adapter) {
return this;
};
+ /**
+ * Select a field that is Null
+ *
+ * @param {String} field - The name of the field that has a NULL value
+ * @return this
+ */
+ this.whereIsNull = function(field) {
+ _p.whereNull(field, 'IS NULL', 'AND');
+ return this;
+ }
+
+ /**
+ * Specify that a field IS NOT NULL
+ *
+ * @param {String} field
+ * @return this
+ */
+ this.whereIsNotNull = function(field) {
+ _p.whereNull(field, 'IS NOT NULL', 'AND');
+ return this;
+ }
+
+ /**
+ * Field is null prefixed with 'OR'
+ *
+ * @param {String} field
+ * @return this
+ */
+ this.orWhereIsNull = function(field) {
+ _p.whereNull(field, 'IS NULL', 'OR');
+ return this;
+ }
+
+ /**
+ * Field is not null prefixed with 'OR'
+ *
+ * @param {String} field
+ * @return this
+ */
+ this.orWhereIsNotNull = function(field) {
+ _p.whereNull(field, 'IS NOT NULL', 'OR');
+ return this;
+ }
+
/**
* Set a 'where in' clause
*
@@ -988,7 +1042,7 @@ module.exports = QueryBuilder;
Documentation generated by JSDoc 3.3.0-alpha9
- on Wed Nov 5th 2014 using the DocStrap template.
diff --git a/docs/query-parser.js.html b/docs/query-parser.js.html
index 74f5e2b..71e0908 100644
--- a/docs/query-parser.js.html
+++ b/docs/query-parser.js.html
@@ -184,7 +184,7 @@ module.exports = QueryParser;
Documentation generated by JSDoc 3.3.0-alpha9
- on Wed Nov 5th 2014 using the DocStrap template.