From ad0ea2602fdc3c7e8816498e96b0ea89bde00a8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Drouyer?= Date: Wed, 24 Oct 2012 00:28:28 +0300 Subject: [PATCH] Fixed bug for IN on NOT IN - corrected When length of values for IN and NOT IN is 0, it causes an SQL error: "IN ()" and "NOT IN ()" doesn't work in MySQL. I corrected my first pull request : https://github.com/1602/jugglingdb/pull/135 --- lib/adapters/mysql.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/adapters/mysql.js b/lib/adapters/mysql.js index 232a38bc..2fd19a06 100644 --- a/lib/adapters/mysql.js +++ b/lib/adapters/mysql.js @@ -238,6 +238,10 @@ MySQL.prototype.all = function all(model, filter, callback) { } else if (conds[key].constructor.name === 'Object') { var condType = Object.keys(conds[key])[0]; var sqlCond = keyEscaped; + if ((condType == 'inq' || condType == 'nin') && val.length == 0) { + cs.push(condType == 'inq' ? 0 : 1); + return true; + } switch (condType) { case 'gt': sqlCond += ' > ';