Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Live query throws error when constraint notEqualTo is set to null #8835

Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions spec/ParseLiveQuery.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1269,4 +1269,37 @@ describe('ParseLiveQuery', function () {
expect(object2.id).toBeDefined();
expect(object3.id).toBeDefined();
});

it('matchesKeyConstraints fails when subscribing a query with constraint notEqualTo null', async () => {
mtrezza marked this conversation as resolved.
Show resolved Hide resolved
await reconfigureServer({
liveQuery: {
classNames: ['TestObject'],
},
startLiveQueryServer: true,
verbose: false,
silent: true,
});

// Creating a spy so we can register it as event listener.
const spy = {
create(obj) {
expect(obj.attributes.foo).toEqual('bar');
},
};
const createSpy = spyOn(spy, 'create');

// Subscribe to TestObject class. where foo is not equal to null
mtrezza marked this conversation as resolved.
Show resolved Hide resolved
const query = new Parse.Query(TestObject);
query.notEqualTo('foo', null);
const subscription = await query.subscribe();
subscription.on('create', spy.create);

// Create a object and save it, the save call passes but server crashes afterwards
mtrezza marked this conversation as resolved.
Show resolved Hide resolved
const object1 = new TestObject();
object1.set('foo', 'bar');
await object1.save();

// Failing test.Since server crashed, it should not have been called.
mtrezza marked this conversation as resolved.
Show resolved Hide resolved
expect(createSpy).toHaveBeenCalledTimes(1);
});
});