Skip to content

Commit

Permalink
fix: Local datastore throws error when Parse.Query.notEqualTo is se…
Browse files Browse the repository at this point in the history
…t to `null` (#2102)
  • Loading branch information
dplewis committed Apr 13, 2024
1 parent fe29e6e commit 6afd32a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
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

0 comments on commit 6afd32a

Please sign in to comment.