timraybould
timraybould

Reputation: 741

Why is Firestore ignoring the 'array_contains' part of this compound query?

The following query is returning results for ("flag","==","someFlag") as if the array_contains part of the query doesn't exist:

myRef
  .collection('someCollection')
  .where("flag","==","someFlag")
  .where("folders","array_contains","test string")
  .get()

My expectation was that this query would produce an error in the console with a link to create a composite index for the two fields in the query. I can create the index myself, but didn't want to do so without trying to fully understand what's going on.

EDIT: This gibberish query has the same effect (returns results for "flag == someFlag"). Shouldn't it throw an error?

myRef
  .collection('someCollection')
  .where("flag","==","someFlag")
  .where("asdf","asdf","asdf")
  .get()

Upvotes: 0

Views: 62

Answers (1)

Renaud Tarnec
Renaud Tarnec

Reputation: 83153

I make the assumption you are using the Web SDK. Note that the syntax is

.where("folders","array-contains","test string")

and not

.where("folders","array_contains","test string")

Upvotes: 1

Related Questions