diff --git a/firestore/google/cloud/firestore_v1/client.py b/firestore/google/cloud/firestore_v1/client.py index 445c7c6bd3de..dd75b00cb76c 100644 --- a/firestore/google/cloud/firestore_v1/client.py +++ b/firestore/google/cloud/firestore_v1/client.py @@ -520,8 +520,9 @@ def _parse_batch_get(get_doc_response, reference_map, client): update_time=get_doc_response.found.update_time, ) elif result_type == "missing": + reference = _get_reference(get_doc_response.missing, reference_map) snapshot = DocumentSnapshot( - None, + reference, None, exists=False, read_time=get_doc_response.read_time, diff --git a/firestore/tests/system.py b/firestore/tests/system.py index a8e683629add..47ad6c935b56 100644 --- a/firestore/tests/system.py +++ b/firestore/tests/system.py @@ -769,6 +769,7 @@ def test_get_all(client, cleanup): assert snapshots[0].exists assert snapshots[1].exists assert not snapshots[2].exists + snapshots = [snapshot for snapshot in snapshots if snapshot.exists] id_attr = operator.attrgetter("id") snapshots.sort(key=id_attr) diff --git a/firestore/tests/unit/v1/test_client.py b/firestore/tests/unit/v1/test_client.py index 117924ec4f53..5fc92479d607 100644 --- a/firestore/tests/unit/v1/test_client.py +++ b/firestore/tests/unit/v1/test_client.py @@ -594,11 +594,16 @@ def test_found(self): self.assertEqual(snapshot.update_time, update_time) def test_missing(self): + from google.cloud.firestore_v1.document import DocumentReference + ref_string = self._dummy_ref_string() response_pb = _make_batch_response(missing=ref_string) - - snapshot = self._call_fut(response_pb, {}) + document = DocumentReference("fizz", "bazz", client=mock.sentinel.client) + reference_map = {ref_string: document} + snapshot = self._call_fut(response_pb, reference_map) self.assertFalse(snapshot.exists) + self.assertEqual(snapshot.id, "bazz") + self.assertIsNone(snapshot._data) def test_unset_result_type(self): response_pb = _make_batch_response()