Closed DavinRot closed 7 months ago
It's definitely broken.
Tried the functions below. The common version doesn't work (returns zero results), but the ones where I use the native versions work as expected.
Tried looking at the source code, but as far as I can tell it should work.
I am using expect/actual as a workaround for now.
// common - Doesn't work (returns zero results)
actual suspend fun query(categories: List<String>): Query =
Firebase.firestore.collection("categories")
.where("name", inArray = categories)
// Android - works (returns seven results as expected)
actual suspend fun query(categories: List<String>): Query = Query(
Firebase.firestore.collection("categories").android
.whereIn("name", categories)
)
// iOS - works (returns seven results as expected)
actual suspend fun query(categories: List<String>): Query = Query(
Firebase.firestore.collection("categories")
.ios.queryWhereFieldPath(FIRFieldPath(listOf("name")), `in` = categories))
It looks like method fun Query.where(field: String, inArray: List<Any>? = null, arrayContainsAny: List<Any>? = null)
internally calls method internal fun _where(field: String, lessThan: Any? = null, greaterThan: Any? = null, arrayContains: Any? = null): Query
instead of method internal fun _where(field: String, inArray: List<Any>? = null, arrayContainsAny: List<Any>? = null): Query
. Internal method that uses array is not even being used.
@Daeda88 has your changes to where clauses fixed this issue now?
Yeah, now it works, thank you
So first off, my assumption about the Query.where method that takes params
field: String, inArray: List<Any>
is that it should be returning a list of all entries from that collection where the field matches an entry in that list (in my case the field is an id and I'm checking against a list of Strings). First off, please correct me if I'm just using the query wrong. Assuming I'm not, I can't get it to work - I keep getting an empty list, but using Query.where withfield: String, equalTo: Any?
and piecing the list together works fine. Is the method bugged, or am I just not using it right?