firebase-tools
firebase-tools copied to clipboard
Firestore Emulator different behavior in the Emulator and Cloud with OrderBy
[REQUIRED] Environment info
firebase-tools: 11.1.0
Platform: MacOs
[REQUIRED] Test case
The code below does not error locally with the emulator, but errors when targeting the cloud db.
let baseQuery = db
.collection('incentives')
.where('startTime', '<=', new Date())
.where('status', '==', IncentiveStatus.Active)
.where('target', '==', target)
.where('valueType', 'in', [
ValueType.Cash,
ValueType.HourlyRate,
ValueType.Rate,
])
.orderBy('startTime')
if (shiftId) {
baseQuery = baseQuery.where('shiftId', '==', shiftId)
}
if (shiftIncentivesOnly) {
baseQuery = baseQuery.orderBy('shiftId') // this is being used to ONLY fetch documents that have this field
}
const ref = await baseQuery.withConverter(defaultConverter<Incentive>()).get()
const startedIncentives = ref.docs.map((doc) => ({
id: doc.id,
...doc.data(),
}))
...
[REQUIRED] Expected behavior
Same errors in the emulator and in the cloud.
[REQUIRED] Actual behavior
The emulator accepts this query and responds correctly.
This issue does not seem to follow the issue template. Make sure you provide all the required information.
@MorenoMdz What is the production error message exactly? If it is related to missing indexes, then you've run into #2027 where Firestore indexes must be explicitly created in production but not the emulator. If so, feel free to close this issue and subscribe / +1 there. If it is something else, please provide as much information about the error as possible.
@MorenoMdz What is the production error message exactly? If it is related to missing indexes, then you've run into #2027 where Firestore indexes must be explicitly created in production but not the emulator. If so, feel free to close this issue and subscribe / +1 there. If it is something else, please provide as much information about the error as possible.
We could close this one, but looks like #2027 has many comments without much attention, we do need to have the same behavior in the emulator and the cloud db ideally.
Closing this one as we are moving from Firestore to a different database.