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:
parent
ee254a1812
commit
e9ff88f453
|
@ -19,6 +19,7 @@ exports.nearFilter = function nearFilter(where) {
|
||||||
parentKeys = parentKeys || [];
|
parentKeys = parentKeys || [];
|
||||||
|
|
||||||
Object.keys(clause).forEach(function(clauseKey) {
|
Object.keys(clause).forEach(function(clauseKey) {
|
||||||
|
if (typeof clause[clauseKey] !== 'object' || !clause[clauseKey]) return;
|
||||||
if (Array.isArray(clause[clauseKey])) {
|
if (Array.isArray(clause[clauseKey])) {
|
||||||
clause[clauseKey].forEach(function(el, index) {
|
clause[clauseKey].forEach(function(el, index) {
|
||||||
var ret = nearSearch(el, parentKeys.concat(clauseKey).concat(index));
|
var ret = nearSearch(el, parentKeys.concat(clauseKey).concat(index));
|
||||||
|
@ -37,7 +38,7 @@ exports.nearFilter = function nearFilter(where) {
|
||||||
key: clauseKey,
|
key: clauseKey,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
var nearResults = [];
|
var nearResults = [];
|
||||||
|
|
|
@ -100,7 +100,7 @@ describe('basic-querying', function() {
|
||||||
db = getSchema();
|
db = getSchema();
|
||||||
var people = [
|
var people = [
|
||||||
{name: 'a', vip: true},
|
{name: 'a', vip: true},
|
||||||
{name: 'b'},
|
{name: 'b', vip: null},
|
||||||
{name: 'c'},
|
{name: 'c'},
|
||||||
{name: 'd', vip: true},
|
{name: 'd', vip: true},
|
||||||
{name: 'e'},
|
{name: 'e'},
|
||||||
|
@ -153,6 +153,20 @@ describe('basic-querying', function() {
|
||||||
done();
|
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() {
|
describe('find', function() {
|
||||||
|
|
Loading…
Reference in New Issue