Skip to content

Commit 6afd32a

Browse files
authored
fix: Local datastore throws error when Parse.Query.notEqualTo is set to null (#2102)
1 parent fe29e6e commit 6afd32a

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

integration/test/ParseLocalDatastoreTest.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1376,6 +1376,16 @@ function runTest(controller) {
13761376
assert.equal(results.length, 9);
13771377
});
13781378

1379+
it(`${controller.name} can perform notEqualTo null queries`, async () => {
1380+
const nullObject = new Parse.Object({ className: 'BoxedNumber', number: null });
1381+
await nullObject.save();
1382+
const query = new Parse.Query('BoxedNumber');
1383+
query.notEqualTo('number', null);
1384+
query.fromLocalDatastore();
1385+
const results = await query.find();
1386+
assert.equal(results.length, 10);
1387+
});
1388+
13791389
it(`${controller.name} can perform containedIn queries`, async () => {
13801390
const query = new Parse.Query('BoxedNumber');
13811391
query.containedIn('number', [3, 5, 7, 9, 11]);

src/OfflineQuery.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -315,11 +315,11 @@ function matchesKeyConstraints(className, object, objects, key, constraints) {
315315
for (const condition in constraints) {
316316
compareTo = constraints[condition];
317317

318-
if (compareTo.__type) {
318+
if (compareTo?.__type) {
319319
compareTo = decode(compareTo);
320320
}
321321
// is it a $relativeTime? convert to date
322-
if (compareTo['$relativeTime']) {
322+
if (compareTo?.['$relativeTime']) {
323323
const parserResult = relativeTimeToDate(compareTo['$relativeTime']);
324324
if (parserResult.status !== 'success') {
325325
throw new ParseError(

0 commit comments

Comments
 (0)