diff --git a/lib/dao.js b/lib/dao.js index d9394963..c5784212 100644 --- a/lib/dao.js +++ b/lib/dao.js @@ -407,6 +407,9 @@ DataAccessObject._coerce = function (where) { } var val = where[p]; + if(val === null || val === undefined) { + continue; + } // Check there is an operator var operator = null; if ('object' === typeof val) { diff --git a/test/loopback-dl.test.js b/test/loopback-dl.test.js index 488c7c86..bd24a623 100644 --- a/test/loopback-dl.test.js +++ b/test/loopback-dl.test.js @@ -654,6 +654,14 @@ describe('DataAccessObject', function () { assert.deepEqual(where, {location: {near: {lng: 10, lat: 20}, maxDistance: 20}}); }); + it('should skip null or undefined values', function () { + where = model._coerce({date: null}); + assert.deepEqual(where, {date: null}); + + where = model._coerce({date: undefined}); + assert.deepEqual(where, {date: undefined}); + }); + }); describe('Load models from json', function () {