Skip to content

[cloud_firestore] Incorrect DocumentReference == equals behavior on the same path on default firestore instance #2081

Closed
@duttaoindril

Description

@duttaoindril

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 🤔

image

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:

  1. 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 DocumentReferences 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.

Metadata

Metadata

Assignees

Labels

impact: customerA bug with low impact (e.g. affecting only a few customers or has a workaround). (P3)plugin: cloud_firestoretype: bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions