Fix/geo null (#1334)

* 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
This commit is contained in:
paulussup 2017-04-25 08:58:11 +09:30 committed by Sakib Hasan
parent ee254a1812
commit e9ff88f453
2 changed files with 17 additions and 2 deletions

View File

@ -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 = [];

View File

@ -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() {