Skip to content

Commit de3aca0

Browse files
fix(firestore): fix get and getall method of transaction (#16)
1 parent 3a37ce9 commit de3aca0

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

‎google/cloud/firestore_v1/transaction.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ def get_all(self, references):
213213
.DocumentSnapshot: The next document snapshot that fulfills the
214214
query, or :data:`None` if the document does not exist.
215215
"""
216-
return self._client.get_all(references, transaction=self._id)
216+
return self._client.get_all(references, transaction=self)
217217

218218
def get(self, ref_or_query):
219219
"""
@@ -225,9 +225,9 @@ def get(self, ref_or_query):
225225
query, or :data:`None` if the document does not exist.
226226
"""
227227
if isinstance(ref_or_query, DocumentReference):
228-
return self._client.get_all([ref_or_query], transaction=self._id)
228+
return self._client.get_all([ref_or_query], transaction=self)
229229
elif isinstance(ref_or_query, Query):
230-
return ref_or_query.stream(transaction=self._id)
230+
return ref_or_query.stream(transaction=self)
231231
else:
232232
raise ValueError(
233233
'Value for argument "ref_or_query" must be a DocumentReference or a Query.'

‎tests/unit/v1/test_transaction.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ def test_get_all(self):
333333
transaction = self._make_one(client)
334334
ref1, ref2 = mock.Mock(), mock.Mock()
335335
result = transaction.get_all([ref1, ref2])
336-
client.get_all.assert_called_once_with([ref1, ref2], transaction=transaction.id)
336+
client.get_all.assert_called_once_with([ref1, ref2], transaction=transaction)
337337
self.assertIs(result, client.get_all.return_value)
338338

339339
def test_get_document_ref(self):
@@ -343,7 +343,7 @@ def test_get_document_ref(self):
343343
transaction = self._make_one(client)
344344
ref = DocumentReference("documents", "doc-id")
345345
result = transaction.get(ref)
346-
client.get_all.assert_called_once_with([ref], transaction=transaction.id)
346+
client.get_all.assert_called_once_with([ref], transaction=transaction)
347347
self.assertIs(result, client.get_all.return_value)
348348

349349
def test_get_w_query(self):
@@ -354,7 +354,7 @@ def test_get_w_query(self):
354354
query = Query(parent=mock.Mock(spec=[]))
355355
query.stream = mock.MagicMock()
356356
result = transaction.get(query)
357-
query.stream.assert_called_once_with(transaction=transaction.id)
357+
query.stream.assert_called_once_with(transaction=transaction)
358358
self.assertIs(result, query.stream.return_value)
359359

360360
def test_get_failure(self):

0 commit comments

Comments
 (0)