Skip to content

Commit 11d3e48

Browse files
fix: Live query throws error when constraint notEqualTo is set to null (#8835)
1 parent 716925e commit 11d3e48

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

spec/ParseLiveQuery.spec.js

+29
Original file line numberDiff line numberDiff line change
@@ -1269,4 +1269,33 @@ describe('ParseLiveQuery', function () {
12691269
expect(object2.id).toBeDefined();
12701270
expect(object3.id).toBeDefined();
12711271
});
1272+
1273+
it('triggers query event with constraint not equal to null', async () => {
1274+
await reconfigureServer({
1275+
liveQuery: {
1276+
classNames: ['TestObject'],
1277+
},
1278+
startLiveQueryServer: true,
1279+
verbose: false,
1280+
silent: true,
1281+
});
1282+
1283+
const spy = {
1284+
create(obj) {
1285+
expect(obj.attributes.foo).toEqual('bar');
1286+
},
1287+
};
1288+
const createSpy = spyOn(spy, 'create');
1289+
const query = new Parse.Query(TestObject);
1290+
query.notEqualTo('foo', null);
1291+
const subscription = await query.subscribe();
1292+
subscription.on('create', spy.create);
1293+
1294+
const object1 = new TestObject();
1295+
object1.set('foo', 'bar');
1296+
await object1.save();
1297+
1298+
await new Promise(resolve => setTimeout(resolve, 100));
1299+
expect(createSpy).toHaveBeenCalledTimes(1);
1300+
});
12721301
});

src/LiveQuery/QueryTools.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ function matchesKeyConstraints(object, key, constraints) {
223223
// More complex cases
224224
for (var condition in constraints) {
225225
compareTo = constraints[condition];
226-
if (compareTo.__type) {
226+
if (compareTo?.__type) {
227227
compareTo = Parse._decode(key, compareTo);
228228
}
229229
switch (condition) {

0 commit comments

Comments
 (0)