Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
duttaoindril opened this issue Feb 28, 2020 · 3 comments
Assignees
Labels
impact: customer A bug with low impact (e.g. affecting only a few customers or has a workaround). (P3) plugin: cloud_firestore type: bug Something isn't working

Comments

@duttaoindril
Copy link

duttaoindril commented Feb 28, 2020

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.

@Ehesp
Copy link
Member

Ehesp commented Apr 20, 2020

The equal check on the instance should be checking the name property, since the reference of the two instances is different (hence the == failing).

@Ehesp Ehesp added plugin: cloud_firestore impact: customer A bug with low impact (e.g. affecting only a few customers or has a workaround). (P3) labels Apr 20, 2020
@duttaoindril
Copy link
Author

duttaoindril commented Apr 21, 2020 via email

@Salakar
Copy link
Member

Salakar commented Jul 7, 2020

Hey @duttaoindril, as part of our on-going work for #2582, this has been resolved in our Firebase Firestore rework (#2913) - which has now been merged into master. We'll look at publishing some prereleases in the next few days. Thank you for raising this issue

@Salakar Salakar closed this as completed Jul 7, 2020
@firebase firebase locked and limited conversation to collaborators Aug 7, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
impact: customer A bug with low impact (e.g. affecting only a few customers or has a workaround). (P3) plugin: cloud_firestore type: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants