Skip to content

Commit 11ef64b

Browse files
committed
Fix implementation of Query to Pipeline for isNan, isNotNan, isNull, and isNotNull changes in the backend
1 parent da10b18 commit 11ef64b

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

packages/firestore/src/core/pipeline-util.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,15 +56,15 @@ export function toPipelineBooleanExpr(f: FilterInternal): BooleanExpression {
5656
const fieldValue = field(f.field.toString());
5757
if (isNanValue(f.value)) {
5858
if (f.op === Operator.EQUAL) {
59-
return and(fieldValue.exists(), fieldValue.isNan());
59+
return and(fieldValue.exists(), fieldValue.equal(constant(NaN)));
6060
} else {
61-
return and(fieldValue.exists(), fieldValue.isNotNan());
61+
return and(fieldValue.exists(), fieldValue.notEqual(constant(NaN)));
6262
}
6363
} else if (isNullValue(f.value)) {
6464
if (f.op === Operator.EQUAL) {
65-
return and(fieldValue.exists(), fieldValue.isNull());
65+
return and(fieldValue.exists(), fieldValue.equal(constant(null)));
6666
} else {
67-
return and(fieldValue.exists(), fieldValue.isNotNull());
67+
return and(fieldValue.exists(), fieldValue.notEqual(constant(null)));
6868
}
6969
} else {
7070
// Comparison filters

packages/firestore/test/integration/api/query_to_pipeline.test.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -648,7 +648,7 @@ const testUnsupportedFeatures: boolean | 'only' = false;
648648
async (collRef, db) => {
649649
const query1 = query(collRef, where('bar', '!=', NaN));
650650
const snapshot = await execute(db.pipeline().createFrom(query1));
651-
verifyResults(snapshot, { foo: 2, bar: 1 });
651+
verifyResults(snapshot, { foo: 2, bar: 1 }, { foo: 3, bar: 'bar' });
652652
}
653653
);
654654
});
@@ -662,8 +662,10 @@ const testUnsupportedFeatures: boolean | 'only' = false;
662662
},
663663
async (collRef, db) => {
664664
const query1 = query(collRef, where('bar', '==', null));
665+
const classicSnapshot = await getDocs(query1);
666+
const classicData = classicSnapshot.docs.map(d => d.data());
665667
const snapshot = await execute(db.pipeline().createFrom(query1));
666-
verifyResults(snapshot, { foo: 1, bar: null });
668+
verifyResults(snapshot, ...classicData);
667669
}
668670
);
669671
});
@@ -677,8 +679,10 @@ const testUnsupportedFeatures: boolean | 'only' = false;
677679
},
678680
async (collRef, db) => {
679681
const query1 = query(collRef, where('bar', '!=', null));
682+
const classicSnapshot = await getDocs(query1);
683+
const classicData = classicSnapshot.docs.map(d => d.data());
680684
const snapshot = await execute(db.pipeline().createFrom(query1));
681-
verifyResults(snapshot, { foo: 2, bar: 1 });
685+
verifyResults(snapshot, ...classicData);
682686
}
683687
);
684688
});

0 commit comments

Comments
 (0)