Skip to content

Commit 68082c3

Browse files
committed
Port null/NaN validation text from iOS
From firebase/firebase-ios-sdk#2670
1 parent 271476b commit 68082c3

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

packages/firestore/src/core/query.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -533,15 +533,15 @@ export class FieldFilter extends Filter {
533533
if (op !== Operator.EQUAL) {
534534
throw new FirestoreError(
535535
Code.INVALID_ARGUMENT,
536-
'Invalid query. You can only perform equals comparisons on null.'
536+
'Invalid query. Null supports only equality comparisons.'
537537
);
538538
}
539539
return new FieldFilter(field, op, value);
540540
} else if (value.isEqual(DoubleValue.NAN)) {
541541
if (op !== Operator.EQUAL) {
542542
throw new FirestoreError(
543543
Code.INVALID_ARGUMENT,
544-
'Invalid query. You can only perform equals comparisons on NaN.'
544+
'Invalid query. NaN supports only equality comparisons.'
545545
);
546546
}
547547
return new FieldFilter(field, op, value);

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

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -815,10 +815,10 @@ apiDescribe('Validation:', (persistence: boolean) => {
815815
db => {
816816
const collection = db.collection('test');
817817
expect(() => collection.where('a', '>', null)).to.throw(
818-
'Invalid query. You can only perform equals comparisons on null.'
818+
'Invalid query. Null supports only equality comparisons.'
819819
);
820820
expect(() => collection.where('a', 'array-contains', null)).to.throw(
821-
'Invalid query. You can only perform equals comparisons on null.'
821+
'Invalid query. Null supports only equality comparisons.'
822822
);
823823
expect(() => collection.where('a', inOp, null)).to.throw(
824824
"Invalid Query. A non-empty array is required for 'in' filters."
@@ -828,13 +828,11 @@ apiDescribe('Validation:', (persistence: boolean) => {
828828
);
829829

830830
expect(() => collection.where('a', '>', Number.NaN)).to.throw(
831-
'Invalid query. You can only perform equals comparisons on NaN.'
831+
'Invalid query. NaN supports only equality comparisons.'
832832
);
833833
expect(() =>
834834
collection.where('a', 'array-contains', Number.NaN)
835-
).to.throw(
836-
'Invalid query. You can only perform equals comparisons on NaN.'
837-
);
835+
).to.throw('Invalid query. NaN supports only equality comparisons.');
838836
expect(() => collection.where('a', inOp, Number.NaN)).to.throw(
839837
"Invalid Query. A non-empty array is required for 'in' filters."
840838
);

0 commit comments

Comments
 (0)