From 6c5666e23e4fd979ac7427ae69f6dcbec3c8d3ef Mon Sep 17 00:00:00 2001 From: Anatoliy Chakkaev Date: Mon, 22 Apr 2013 08:40:12 +0400 Subject: [PATCH] Add checking for undefined in buildWhere --- lib/mysql.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/mysql.js b/lib/mysql.js index 2f09bec..5cc6e3f 100644 --- a/lib/mysql.js +++ b/lib/mysql.js @@ -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) {