Add checking for undefined in buildWhere

This commit is contained in:
Anatoliy Chakkaev 2013-04-22 08:40:12 +04:00
parent 400614a8c9
commit 6c5666e23e
1 changed files with 2 additions and 2 deletions

View File

@ -261,9 +261,9 @@ MySQL.prototype.all = function all(model, filter, callback) {
Object.keys(conds).forEach(function (key) {
var keyEscaped = '`' + key.replace(/\./g, '`.`') + '`'
var val = self.toDatabase(props[key], conds[key]);
if (conds[key] === null) {
if (conds[key] === null || conds[key] === undefined) {
cs.push(keyEscaped + ' IS NULL');
} else if (conds[key].constructor.name === 'Object') {
} else if (conds[key] && conds[key].constructor.name === 'Object') {
var condType = Object.keys(conds[key])[0];
var sqlCond = keyEscaped;
if ((condType == 'inq' || condType == 'nin') && val.length == 0) {