-
Notifications
You must be signed in to change notification settings - Fork 83
Closed
Labels
api: firestoreIssues related to the googleapis/python-firestore API.Issues related to the googleapis/python-firestore API.priority: p2Moderately-important priority. Fix may not be included in next release.Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Description
Environment details
- Specify the API at the beginning of the title: Firestore
- OS type and version: MacOS 10.15.2
- Python version and virtual environment information:
python --version: Python 3.7.4 - google-cloud- version:
pip show google-<service>orpip freeze: google-cloud-firestore==1.6.1
Steps to reproduce
- Create a document in your firestore database.
- Run the code below, which will raise an
AttributeError: 'bytes' object has no attribute 'in_progress'.
Code example
transaction = db.transaction()
doc_ref = ... # get a reference to the document you created in step 1 above
@firestore.transactional
def update_in_transaction(transaction, doc_ref):
docs = transaction.get(doc_ref)
for doc in docs:
print(doc)Stack trace
# Abbreviated stack trace
File ".../venv/lib/python3.7/site-packages/google/cloud/firestore_v1/client.py", line 440, in get_all
transaction=_helpers.get_transaction_id(transaction),
File ".../venv/lib/python3.7/site-packages/google/cloud/firestore_v1/_helpers.py", line 934, in get_transaction_id
if not transaction.in_progress:
AttributeError: 'bytes' object has no attribute 'in_progress'
Additional Notes
It appears the helper function get_transaction_id is expecting a Transaction object, but both the Transaction.get() and Transaction.get_all() calls are passing a Transaction._id.
When I changed line 230 of transaction.py from:
return ref_or_query.stream(transaction=self._id)
to:
return ref_or_query.stream(transaction=self)
It appears to fix the issue.
Metadata
Metadata
Assignees
Labels
api: firestoreIssues related to the googleapis/python-firestore API.Issues related to the googleapis/python-firestore API.priority: p2Moderately-important priority. Fix may not be included in next release.Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.Error or flaw in code with unintended results or allowing sub-optimal usage patterns.