Description
Describe the bug
When doing an equals on two document references:
DocumentReference docA = Firestore.instance.collection(“foo”).document(“bar”);
DocumentReference docB = Firestore.instance.collection(“foo”).document(“bar”);
print(docA == docB); // false
When diving into the issue a bit, I found the source code for DocumentReference ==
checks the path and the firestore instance.
The path is equal, so when I looked at the two firestore instances, even though they're both from the same default app, (only one firebase app in my project), they're not equal.
// ...continued from above
print(docA.firestore == docB.firestore); // false
I didn't get a chance to dive deeper into why the above equals check doesn't work, but upon inspecting the firestore instances, I saw the default firebase app doesn't have the same hashcode across the two firestore instances 🤔
That might be a helpful tip. Maybe look into the equals for firestore / firebase? Maybe always kick back true if both firestore instances are from the default app?
To Reproduce
Steps to reproduce the behavior:
- Run the code above and see the output
Expected behavior
Document references with the same path from the same default firestore instance should be equal.
Additional context
This may or may not be also messing up usage of DocumentReference
s as a viable key in a map - lookups to maps with the DocumentReference
as it's key randomly doesn't work, which may or may not be due to this issue.