Skip to content

Commit 6069b1d

Browse files
author
Brian Chen
authored
Update outdated error message to include '!=' (#4262)
1 parent 487f8e1 commit 6069b1d

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

.changeset/metal-paws-joke.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@firebase/firestore': minor
3+
---
4+
5+
Updated an outdated error message to include '!=' and 'not-in' as an inequalities.

packages/firestore/src/lite/query.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -795,7 +795,7 @@ function validateNewFilter(query: InternalQuery, filter: Filter): void {
795795
throw new FirestoreError(
796796
Code.INVALID_ARGUMENT,
797797
'Invalid query. All where filters with an inequality' +
798-
' (<, <=, >, or >=) must be on the same field. But you have' +
798+
' (<, <=, !=, not-in, >, or >=) must be on the same field. But you have' +
799799
` inequality filters on '${existingField.toString()}'` +
800800
` and '${filter.field.toString()}'`
801801
);
@@ -845,7 +845,7 @@ function validateOrderByAndInequalityMatch(
845845
throw new FirestoreError(
846846
Code.INVALID_ARGUMENT,
847847
`Invalid query. You have a where filter with an inequality ` +
848-
`(<, <=, >, or >=) on field '${inequality.toString()}' ` +
848+
`(<, <=, !=, not-in, >, or >=) on field '${inequality.toString()}' ` +
849849
`and so you must also use '${inequality.toString()}' ` +
850850
`as your first argument to orderBy(), but your first orderBy() ` +
851851
`is on field '${orderBy.toString()}' instead.`

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

+4-4
Original file line numberDiff line numberDiff line change
@@ -797,7 +797,7 @@ apiDescribe('Validation:', (persistence: boolean) => {
797797
collection.where('x', '>=', 32).where('y', '<', 'cat')
798798
).to.throw(
799799
'Invalid query. All where filters with an ' +
800-
'inequality (<, <=, >, or >=) must be on the same field.' +
800+
'inequality (<, <=, !=, not-in, >, or >=) must be on the same field.' +
801801
` But you have inequality filters on 'x' and 'y'`
802802
);
803803
});
@@ -818,7 +818,7 @@ apiDescribe('Validation:', (persistence: boolean) => {
818818
collection.where('y', '>', 32).where('x', '!=', 33)
819819
).to.throw(
820820
'Invalid query. All where filters with an ' +
821-
'inequality (<, <=, >, or >=) must be on the same field.' +
821+
'inequality (<, <=, !=, not-in, >, or >=) must be on the same field.' +
822822
` But you have inequality filters on 'y' and 'x`
823823
);
824824
}
@@ -833,7 +833,7 @@ apiDescribe('Validation:', (persistence: boolean) => {
833833
collection.where('y', '>', 32).where('x', 'not-in', [33])
834834
).to.throw(
835835
'Invalid query. All where filters with an ' +
836-
'inequality (<, <=, >, or >=) must be on the same field.' +
836+
'inequality (<, <=, !=, not-in, >, or >=) must be on the same field.' +
837837
` But you have inequality filters on 'y' and 'x`
838838
);
839839
}
@@ -846,7 +846,7 @@ apiDescribe('Validation:', (persistence: boolean) => {
846846
const collection = db.collection('test');
847847
const reason =
848848
`Invalid query. You have a where filter with an ` +
849-
`inequality (<, <=, >, or >=) on field 'x' and so you must also ` +
849+
`inequality (<, <=, !=, not-in, >, or >=) on field 'x' and so you must also ` +
850850
`use 'x' as your first argument to Query.orderBy(), but your first ` +
851851
`orderBy() is on field 'y' instead.`;
852852
expect(() => collection.where('x', '>', 32).orderBy('y')).to.throw(

0 commit comments

Comments
 (0)