Skip to content

Commit efd4ed1

Browse files
author
Brian Chen
committed
resolve gil comments
1 parent 4a6ea59 commit efd4ed1

File tree

3 files changed

+29
-15
lines changed

3 files changed

+29
-15
lines changed

.changeset/wicked-cups-search.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
'@firebase/firestore': minor
33
---
44

5-
Removed validation of `null` and `NaN` values in filters. However, note that only `==` and `!=` filters match against `null` and `NaN`.
5+
Removed excess validation of null and NaN values in query filters. This more closely aligns the SDK with the Firestore backend, which has always accepted null and NaN for all operators, even though this isn't necessarily useful.

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

+28-6
Original file line numberDiff line numberDiff line change
@@ -818,9 +818,19 @@ apiDescribe('Queries', (persistence: boolean) => {
818818
const snapshot3 = await coll.where('zip', 'in', [null]).get();
819819
expect(toDataArray(snapshot3)).to.deep.equal([]);
820820

821+
// With null and a value.
822+
const snapshot4 = await coll.where('zip', 'in', [98101, null]).get();
823+
expect(toDataArray(snapshot4)).to.deep.equal([{ zip: 98101 }]);
824+
821825
// With NaN.
822-
const snapshot4 = await coll.where('zip', 'in', [Number.NaN]).get();
823-
expect(toDataArray(snapshot4)).to.deep.equal([]);
826+
const snapshot5 = await coll.where('zip', 'in', [Number.NaN]).get();
827+
expect(toDataArray(snapshot5)).to.deep.equal([]);
828+
829+
// With NaN and a value.
830+
const snapshot6 = await coll
831+
.where('zip', 'in', [98101, Number.NaN])
832+
.get();
833+
expect(toDataArray(snapshot6)).to.deep.equal([{ zip: 98101 }]);
824834
});
825835
});
826836

@@ -958,15 +968,27 @@ apiDescribe('Queries', (persistence: boolean) => {
958968

959969
// With null.
960970
const snapshot3 = await coll
961-
.where('zip', 'array-contains-any', [null])
971+
.where('array', 'array-contains-any', [null])
962972
.get();
963973
expect(toDataArray(snapshot3)).to.deep.equal([]);
964974

965-
// With NaN.
975+
// With null and a value.
966976
const snapshot4 = await coll
967-
.where('zip', 'array-contains-any', [Number.NaN])
977+
.where('array', 'array-contains-any', [43, null])
968978
.get();
969-
expect(toDataArray(snapshot4)).to.deep.equal([]);
979+
expect(toDataArray(snapshot4)).to.deep.equal([{ array: [43] }]);
980+
981+
// With NaN.
982+
const snapshot5 = await coll
983+
.where('array', 'array-contains-any', [Number.NaN])
984+
.get();
985+
expect(toDataArray(snapshot5)).to.deep.equal([]);
986+
987+
// With NaN and a value.
988+
const snapshot6 = await coll
989+
.where('array', 'array-contains-any', [43, Number.NaN])
990+
.get();
991+
expect(toDataArray(snapshot6)).to.deep.equal([{ array: [43] }]);
970992
});
971993
});
972994

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

-8
Original file line numberDiff line numberDiff line change
@@ -711,14 +711,6 @@ apiDescribe('Validation:', (persistence: boolean) => {
711711
);
712712
});
713713

714-
validationIt(persistence, 'enum', db => {
715-
const collection = db.collection('test') as any;
716-
expect(() => collection.where('a', 'foo' as any, 'b')).to.throw(
717-
'Invalid value "foo" provided to function Query.where() for its second argument. ' +
718-
'Acceptable values: <, <=, ==, !=, >=, >, array-contains, in, array-contains-any, not-in'
719-
);
720-
});
721-
722714
it('cannot be created from documents missing sort values', () => {
723715
const testDocs = {
724716
f: { k: 'f', nosort: 1 } // should not show up

0 commit comments

Comments
 (0)