Check for null & undefined values

This commit is contained in:
Raymond Feng 2013-12-14 09:54:28 -08:00
parent fab504b5d9
commit 9890af119e
2 changed files with 11 additions and 0 deletions

View File

@ -407,6 +407,9 @@ DataAccessObject._coerce = function (where) {
} }
var val = where[p]; var val = where[p];
if(val === null || val === undefined) {
continue;
}
// Check there is an operator // Check there is an operator
var operator = null; var operator = null;
if ('object' === typeof val) { if ('object' === typeof val) {

View File

@ -654,6 +654,14 @@ describe('DataAccessObject', function () {
assert.deepEqual(where, {location: {near: {lng: 10, lat: 20}, maxDistance: 20}}); 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 () { describe('Load models from json', function () {