Add checking for undefined in buildWhere
This commit is contained in:
parent
400614a8c9
commit
6c5666e23e
|
@ -261,9 +261,9 @@ MySQL.prototype.all = function all(model, filter, callback) {
|
||||||
Object.keys(conds).forEach(function (key) {
|
Object.keys(conds).forEach(function (key) {
|
||||||
var keyEscaped = '`' + key.replace(/\./g, '`.`') + '`'
|
var keyEscaped = '`' + key.replace(/\./g, '`.`') + '`'
|
||||||
var val = self.toDatabase(props[key], conds[key]);
|
var val = self.toDatabase(props[key], conds[key]);
|
||||||
if (conds[key] === null) {
|
if (conds[key] === null || conds[key] === undefined) {
|
||||||
cs.push(keyEscaped + ' IS NULL');
|
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 condType = Object.keys(conds[key])[0];
|
||||||
var sqlCond = keyEscaped;
|
var sqlCond = keyEscaped;
|
||||||
if ((condType == 'inq' || condType == 'nin') && val.length == 0) {
|
if ((condType == 'inq' || condType == 'nin') && val.length == 0) {
|
||||||
|
|
Loading…
Reference in New Issue