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
This commit is contained in:
Sébastien Drouyer 2012-10-24 00:28:28 +03:00
parent c27a624d02
commit ad0ea2602f
1 changed files with 4 additions and 0 deletions

View File

@ -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 += ' > ';