Skip to content

Commit

Permalink
Fix/geo null (#1334)
Browse files Browse the repository at this point in the history
* fix check for null

* add tests

* fix for early return

* Allow check for null and non-existent value

Some connectors uses a non existent prop instead of allowing null
Modified test case to look if null exists or the prop is non existent

* Check for null value with geo near query

* Apply requested changes

* change test to two users and simplify

* check error first

* Fix simple query test case with null value

* BDD for connectors w//o null support
  • Loading branch information
paulussup authored and Sakib Hasan committed Apr 24, 2017
1 parent ee254a1 commit e9ff88f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
3 changes: 2 additions & 1 deletion lib/geo.js
Expand Up @@ -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));
Expand All @@ -37,7 +38,7 @@ exports.nearFilter = function nearFilter(where) {
key: clauseKey,
});
}
}
};
});
}
var nearResults = [];
Expand Down
16 changes: 15 additions & 1 deletion test/basic-querying.test.js
Expand Up @@ -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'},
Expand Down Expand Up @@ -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() {
Expand Down

0 comments on commit e9ff88f

Please sign in to comment.