python-mock-firestore
python-mock-firestore copied to clipboard
Add equality and hash functions to DocumentReference to fix reference querying
Currently, querying documents by a reference field (e.g. .where("reference_field", "==", reference)) results in incorrect results due to document references not being compared properly. Even if there are documents with references that have the same path as the document reference passed into the query, no documents get returned.
To address this, I've implemented __eq__ and __hash__ to be more similar to the actual BaseDocumentReference implementations (see here and here). _client is included in the original implementation, but is not present in mocked base document. Therefore, I've opted to only hash / compare _path.