From f9c61764b003da865bf2342c02a9c5dbe171942b Mon Sep 17 00:00:00 2001 From: Brian Chen Date: Tue, 5 Jan 2021 13:26:09 -0600 Subject: [PATCH 1/3] Update outdated error message to include '!=' --- .changeset/metal-paws-joke.md | 5 +++++ packages/firestore/src/lite/query.ts | 4 ++-- .../firestore/test/integration/api/validation.test.ts | 8 ++++---- 3 files changed, 11 insertions(+), 6 deletions(-) create mode 100644 .changeset/metal-paws-joke.md diff --git a/.changeset/metal-paws-joke.md b/.changeset/metal-paws-joke.md new file mode 100644 index 00000000000..f6896a7fccd --- /dev/null +++ b/.changeset/metal-paws-joke.md @@ -0,0 +1,5 @@ +--- +'@firebase/firestore': minor +--- + +Updated an outdated error message to include '!=' as an inequality. diff --git a/packages/firestore/src/lite/query.ts b/packages/firestore/src/lite/query.ts index b148b5a942e..6feec9113e9 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' + + ' (<, <=, !=, >, 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()}' ` + + `(<, <=, !=, >, 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..a7d8d478574 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 (<, <=, !=, >, 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 (<, <=, !=, >, 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 (<, <=, !=, >, 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 (<, <=, !=, >, 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( From 41bbf72044a1731ec1b4b6487c597b0853afea0b Mon Sep 17 00:00:00 2001 From: Brian Chen Date: Tue, 5 Jan 2021 14:02:26 -0600 Subject: [PATCH 2/3] add not-in --- packages/firestore/src/lite/query.ts | 4 ++-- .../firestore/test/integration/api/validation.test.ts | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/firestore/src/lite/query.ts b/packages/firestore/src/lite/query.ts index 6feec9113e9..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 a7d8d478574..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( From 48d1fc824b2b6731c5532132722452bf5489f368 Mon Sep 17 00:00:00 2001 From: Brian Chen Date: Tue, 5 Jan 2021 14:13:31 -0600 Subject: [PATCH 3/3] update changeset --- .changeset/metal-paws-joke.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/metal-paws-joke.md b/.changeset/metal-paws-joke.md index f6896a7fccd..fe06475f2cc 100644 --- a/.changeset/metal-paws-joke.md +++ b/.changeset/metal-paws-joke.md @@ -2,4 +2,4 @@ '@firebase/firestore': minor --- -Updated an outdated error message to include '!=' as an inequality. +Updated an outdated error message to include '!=' and 'not-in' as an inequalities.