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: Local datastore throws error when Parse.Query.notEqualTo is set to null #2102

Merged
merged 4 commits into from
Apr 13, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
10 changes: 10 additions & 0 deletions integration/test/ParseLocalDatastoreTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -1376,6 +1376,16 @@ function runTest(controller) {
assert.equal(results.length, 9);
});

it(`${controller.name} can perform notEqualTo null queries`, async () => {
const nullObject = new Parse.Object({ className: 'BoxedNumber', number: null });
await nullObject.save();
const query = new Parse.Query('BoxedNumber');
query.notEqualTo('number', null);
query.fromLocalDatastore();
const results = await query.find();
assert.equal(results.length, 10);
});

it(`${controller.name} can perform containedIn queries`, async () => {
const query = new Parse.Query('BoxedNumber');
query.containedIn('number', [3, 5, 7, 9, 11]);
Expand Down
4 changes: 2 additions & 2 deletions src/OfflineQuery.js
Original file line number Diff line number Diff line change
Expand Up @@ -315,11 +315,11 @@ function matchesKeyConstraints(className, object, objects, key, constraints) {
for (const condition in constraints) {
compareTo = constraints[condition];

if (compareTo.__type) {
if (compareTo?.__type) {
compareTo = decode(compareTo);
}
// is it a $relativeTime? convert to date
if (compareTo['$relativeTime']) {
if (compareTo?.['$relativeTime']) {
const parserResult = relativeTimeToDate(compareTo['$relativeTime']);
if (parserResult.status !== 'success') {
throw new ParseError(
Expand Down
Loading