diff --git a/lib/geo.js b/lib/geo.js index 08f8354d..fd2c4737 100644 --- a/lib/geo.js +++ b/lib/geo.js @@ -19,6 +19,7 @@ exports.nearFilter = function nearFilter(where) { parentKeys = parentKeys || []; Object.keys(clause).forEach(function(clauseKey) { + if (typeof clause[clauseKey] !== 'object' || !clause[clauseKey]) return; if (Array.isArray(clause[clauseKey])) { clause[clauseKey].forEach(function(el, index) { var ret = nearSearch(el, parentKeys.concat(clauseKey).concat(index)); @@ -37,7 +38,7 @@ exports.nearFilter = function nearFilter(where) { key: clauseKey, }); } - } + }; }); } var nearResults = []; diff --git a/test/basic-querying.test.js b/test/basic-querying.test.js index 9b1ea00a..9adf6092 100644 --- a/test/basic-querying.test.js +++ b/test/basic-querying.test.js @@ -100,7 +100,7 @@ describe('basic-querying', function() { db = getSchema(); var people = [ {name: 'a', vip: true}, - {name: 'b'}, + {name: 'b', vip: null}, {name: 'c'}, {name: 'd', vip: true}, {name: 'e'}, @@ -153,6 +153,20 @@ describe('basic-querying', function() { done(); }); }); + + bdd.itIf(connectorCapabilities.nullDataValueExists !== false, + 'should query by ids to check null property', function(done) { + User.findByIds([ + createdUsers[0].id, + createdUsers[1].id], + {where: {vip: null}}, function(err, users) { + should.not.exist(err); + should.exist(users); + users.length.should.eql(1); + users[0].name.should.eql(createdUsers[1].name); + done(); + }); + }); }); describe('find', function() {