react-native-firebase
react-native-firebase copied to clipboard
[🐛] Cannot execute query with inequality operator and orderBy different field
Issue
Error is happenning when executing a compound query. Error caused by this line https://github.com/invertase/react-native-firebase/blob/f0cba0bdc0eb36693cf77baa22e214b6cfa674eb/packages/firestore/lib/FirestoreQueryModifiers.js#L406
Describe your issue here: I query with where clause that has inequality operator and a different orderBy clause. It works well with an official JS SDK.
Environment
Bare react-native app.
- Platform that you're experiencing the issue on:
- [ ] iOS
- [ ] Android
- [x] iOS but have not tested behavior on Android
- [ ] Android but have not tested behavior on iOS
- [ ] Both
Hi there! You've removed the version information from the template, can you post what version of firebase-js-sdk and react-native-firebase you've used to come to your conclusions? Can you post a sample query that works on the version of firebase-js-sdk indicated and fails on the version of react-native-firebase indicated?
Thank you
@mikehardy I use the library https://github.com/vpishuk/react-query-firebase that incorporates JS SDK and react-native-firebase.
Versions:
"@react-native-firebase/analytics": "^21.13.0",
"@react-native-firebase/app": "^21.13.0",
"@react-native-firebase/auth": "^21.13.0",
"@react-native-firebase/crashlytics": "^21.13.0",
"@react-native-firebase/firestore": "^21.13.0",
"@react-native-firebase/installations": "^21.13.0",
"@react-native-firebase/remote-config": "^21.13.0",
"firebase": "^11.0.0",
Simplified version of a query:
query: {
operator: "AND",
children: [
{
operator: "OR",
children: [
{ field: "status", op: "in", value: ["1"] },
{
operator: "AND",
children: [
{ field: "status", op: "in", value: ["2"] },
{ field: "completedOn", op: "<=", value: endOfWeek(Date.now()).toISOString() },
{ field: "completedOn", op: ">=", value: startOfWeek(Date.now()).toISOString() }
]
}
]
},
{
field: "type",
op: "==",
value: "xxx"
},
{
field: "documentId",
op: "not-in",
value: ['id1']
}
]
}
order: { by: "counter", direction: "asc" },
Given the error, try ensuring that the inequality comes at the end of the query and the orderBy is executed before.
Hello 👋, to help manage issues we automatically close stale issues.
This issue has been automatically marked as stale because it has not had activity for quite some time.Has this issue been fixed, or does it still require attention?
This issue will be closed in 15 days if no further activity occurs.
Thank you for your contributions.
This is not stale
- see https://github.com/invertase/react-native-firebase/discussions/8745
- also #8161