diff --git a/.changeset/metal-paws-joke.md b/.changeset/metal-paws-joke.md new file mode 100644 index 00000000000..fe06475f2cc --- /dev/null +++ b/.changeset/metal-paws-joke.md @@ -0,0 +1,5 @@ +--- +'@firebase/firestore': minor +--- + +Updated an outdated error message to include '!=' and 'not-in' as an inequalities. diff --git a/packages/firestore/src/lite/query.ts b/packages/firestore/src/lite/query.ts index b148b5a942e..3063e52b8f4 100644 --- a/packages/firestore/src/lite/query.ts +++ b/packages/firestore/src/lite/query.ts @@ -795,7 +795,7 @@ function validateNewFilter(query: InternalQuery, filter: Filter): void { throw new FirestoreError( Code.INVALID_ARGUMENT, 'Invalid query. All where filters with an inequality' + - ' (<, <=, >, or >=) must be on the same field. But you have' + + ' (<, <=, !=, not-in, >, or >=) must be on the same field. But you have' + ` inequality filters on '${existingField.toString()}'` + ` and '${filter.field.toString()}'` ); @@ -845,7 +845,7 @@ function validateOrderByAndInequalityMatch( throw new FirestoreError( Code.INVALID_ARGUMENT, `Invalid query. You have a where filter with an inequality ` + - `(<, <=, >, or >=) on field '${inequality.toString()}' ` + + `(<, <=, !=, not-in, >, or >=) on field '${inequality.toString()}' ` + `and so you must also use '${inequality.toString()}' ` + `as your first argument to orderBy(), but your first orderBy() ` + `is on field '${orderBy.toString()}' instead.` diff --git a/packages/firestore/test/integration/api/validation.test.ts b/packages/firestore/test/integration/api/validation.test.ts index dc1102432e4..ec56d625bee 100644 --- a/packages/firestore/test/integration/api/validation.test.ts +++ b/packages/firestore/test/integration/api/validation.test.ts @@ -797,7 +797,7 @@ apiDescribe('Validation:', (persistence: boolean) => { collection.where('x', '>=', 32).where('y', '<', 'cat') ).to.throw( 'Invalid query. All where filters with an ' + - 'inequality (<, <=, >, or >=) must be on the same field.' + + 'inequality (<, <=, !=, not-in, >, or >=) must be on the same field.' + ` But you have inequality filters on 'x' and 'y'` ); }); @@ -818,7 +818,7 @@ apiDescribe('Validation:', (persistence: boolean) => { collection.where('y', '>', 32).where('x', '!=', 33) ).to.throw( 'Invalid query. All where filters with an ' + - 'inequality (<, <=, >, or >=) must be on the same field.' + + 'inequality (<, <=, !=, not-in, >, or >=) must be on the same field.' + ` But you have inequality filters on 'y' and 'x` ); } @@ -833,7 +833,7 @@ apiDescribe('Validation:', (persistence: boolean) => { collection.where('y', '>', 32).where('x', 'not-in', [33]) ).to.throw( 'Invalid query. All where filters with an ' + - 'inequality (<, <=, >, or >=) must be on the same field.' + + 'inequality (<, <=, !=, not-in, >, or >=) must be on the same field.' + ` But you have inequality filters on 'y' and 'x` ); } @@ -846,7 +846,7 @@ apiDescribe('Validation:', (persistence: boolean) => { const collection = db.collection('test'); const reason = `Invalid query. You have a where filter with an ` + - `inequality (<, <=, >, or >=) on field 'x' and so you must also ` + + `inequality (<, <=, !=, not-in, >, or >=) on field 'x' and so you must also ` + `use 'x' as your first argument to Query.orderBy(), but your first ` + `orderBy() is on field 'y' instead.`; expect(() => collection.where('x', '>', 32).orderBy('y')).to.throw(