简体   繁体   中英

Why does the not equal to where clause query need an order by in firestore?

I think there is an issue with firebase firestore code base for error logging. I'm getting:

Invalid query.... You have a where filter with an inequality (<, <=, >, or >=) on field 'myDocField' and so you must also use 'myDocField' as your first argument to Query.orderBy(), but your first orderBy() is on field 'someOtherDocField' instead.

However, my query is using the ".=" evaluation and no greaterThan/lessThan checks.

So my query is:

myQuery = myReference.where("myDocField", "!=", 0).orderBy("someOtherDocField");

And it plays nice and just wants a composite index when I do:

myQuery = myReference.where("myDocField", "!=", 0).orderBy("myDocField").orderBy("someOtherDocField");

My firebase version is 6.14.10.

So I guess my specific question is why am I getting this error?

Naming wise it makes sense that != is also considered an "inequality" that the message talks about, especially since following the guidance in the error message seems to make it disappear.

My guess is that the error message hasn't been updated for the addition of != queries. It might be worth reporting this issue on the Github repo of the SDK.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM