Skip to content

Commit d8dc524

Browse files
author
Jason Posthuma
authored
Add check for property (#7421)
* Add check for property * updated changelog * Fixed logic returning false positive * Added test case * update change log
1 parent 3a2afda commit d8dc524

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed

Diff for: CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ ___
134134
- Add NPM package-lock version check to CI (Manuel Trezza) [#7333](https://github.com/parse-community/parse-server/pull/7333)
135135
- Fix incorrect LiveQuery events triggered for multiple subscriptions on the same class with different events [#7341](https://github.com/parse-community/parse-server/pull/7341)
136136
- Fix select and excludeKey queries to properly accept JSON string arrays. Also allow nested fields in exclude (Corey Baker) [#7242](https://github.com/parse-community/parse-server/pull/7242)
137+
- Fix LiveQuery server crash when using $all query operator on a missing object key (Jason Posthuma) [#7421](https://github.com/parse-community/parse-server/pull/7421)
137138

138139
___
139140
## 4.5.0

Diff for: spec/QueryTools.spec.js

+10
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,16 @@ describe('matchesQuery', function () {
313313
expect(matchesQuery(player, orQuery)).toBe(true);
314314
});
315315

316+
it('does not match $all query when value is missing', () => {
317+
const player = {
318+
id: new Id('Player', 'P1'),
319+
name: 'Player 1',
320+
score: 12,
321+
};
322+
const q = { missing: { $all: [1, 2, 3] } };
323+
expect(matchesQuery(player, q)).toBe(false);
324+
});
325+
316326
it('matches an $and query', () => {
317327
const player = {
318328
id: new Id('Player', 'P1'),

Diff for: src/LiveQuery/QueryTools.js

+3
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,9 @@ function matchesKeyConstraints(object, key, constraints) {
253253
}
254254
break;
255255
case '$all':
256+
if (!object[key]) {
257+
return false;
258+
}
256259
for (i = 0; i < compareTo.length; i++) {
257260
if (object[key].indexOf(compareTo[i]) < 0) {
258261
return false;

0 commit comments

Comments
 (0)