diff --git a/spec/ParseLiveQuery.spec.js b/spec/ParseLiveQuery.spec.js index 015725ac46..789898f62a 100644 --- a/spec/ParseLiveQuery.spec.js +++ b/spec/ParseLiveQuery.spec.js @@ -1269,4 +1269,33 @@ describe('ParseLiveQuery', function () { expect(object2.id).toBeDefined(); expect(object3.id).toBeDefined(); }); + + it('triggers query event with constraint not equal to null', async () => { + await reconfigureServer({ + liveQuery: { + classNames: ['TestObject'], + }, + startLiveQueryServer: true, + verbose: false, + silent: true, + }); + + const spy = { + create(obj) { + expect(obj.attributes.foo).toEqual('bar'); + }, + }; + const createSpy = spyOn(spy, 'create'); + const query = new Parse.Query(TestObject); + query.notEqualTo('foo', null); + const subscription = await query.subscribe(); + subscription.on('create', spy.create); + + const object1 = new TestObject(); + object1.set('foo', 'bar'); + await object1.save(); + + await new Promise(resolve => setTimeout(resolve, 100)); + expect(createSpy).toHaveBeenCalledTimes(1); + }); }); diff --git a/src/LiveQuery/QueryTools.js b/src/LiveQuery/QueryTools.js index 1607278f46..a839918088 100644 --- a/src/LiveQuery/QueryTools.js +++ b/src/LiveQuery/QueryTools.js @@ -223,7 +223,7 @@ function matchesKeyConstraints(object, key, constraints) { // More complex cases for (var condition in constraints) { compareTo = constraints[condition]; - if (compareTo.__type) { + if (compareTo?.__type) { compareTo = Parse._decode(key, compareTo); } switch (condition) {