Merge pull request #1250 from andrecardoso/live-query-server-matching-does-not-exist-queries
Matching queries with doesNotExist constraint
This commit is contained in:
@@ -112,6 +112,20 @@ describe('matchesQuery', function() {
|
|||||||
expect(matchesQuery(obj, q)).toBe(false);
|
expect(matchesQuery(obj, q)).toBe(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('matches queries with doesNotExist constraint', function() {
|
||||||
|
var obj = {
|
||||||
|
id: new Id('Item', 'O1'),
|
||||||
|
count: 15
|
||||||
|
};
|
||||||
|
var q = new Parse.Query('Item');
|
||||||
|
q.doesNotExist('name');
|
||||||
|
expect(matchesQuery(obj, q)).toBe(true);
|
||||||
|
|
||||||
|
q = new Parse.Query('Item');
|
||||||
|
q.doesNotExist('count');
|
||||||
|
expect(matchesQuery(obj, q)).toBe(false);
|
||||||
|
});
|
||||||
|
|
||||||
it('matches on equality queries', function() {
|
it('matches on equality queries', function() {
|
||||||
var day = new Date();
|
var day = new Date();
|
||||||
var location = new Parse.GeoPoint({
|
var location = new Parse.GeoPoint({
|
||||||
|
|||||||
@@ -206,7 +206,9 @@ function matchesKeyConstraints(object, key, constraints) {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case '$exists':
|
case '$exists':
|
||||||
if (typeof object[key] === 'undefined') {
|
let propertyExists = typeof object[key] !== 'undefined';
|
||||||
|
let existenceIsRequired = constraints['$exists'];
|
||||||
|
if ((!propertyExists && existenceIsRequired) || (propertyExists && !existenceIsRequired)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in New Issue
Block a user