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

Firestore: Can't get data in transaction.get call #8

Closed
mpkasp opened this issue Jan 8, 2020 · 1 comment · Fixed by #16
Closed

Firestore: Can't get data in transaction.get call #8

mpkasp opened this issue Jan 8, 2020 · 1 comment · Fixed by #16
Assignees
Labels
api: firestore Issues related to the googleapis/python-firestore API. priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@mpkasp
Copy link

mpkasp commented Jan 8, 2020

Environment details

  1. Specify the API at the beginning of the title: Firestore
  2. OS type and version: MacOS 10.15.2
  3. Python version and virtual environment information: python --version: Python 3.7.4
  4. google-cloud- version: pip show google-<service> or pip freeze: google-cloud-firestore==1.6.1

Steps to reproduce

  1. Create a document in your firestore database.
  2. 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.

@mpkasp
Copy link
Author

mpkasp commented Jan 8, 2020

So this still seems to be an issue, but as a workaround the example code here seems to run fine.

@HemangChothani HemangChothani self-assigned this Jan 9, 2020
@crwilcox crwilcox transferred this issue from googleapis/google-cloud-python Jan 31, 2020
@product-auto-label product-auto-label bot added the api: firestore Issues related to the googleapis/python-firestore API. label Jan 31, 2020
@yoshi-automation yoshi-automation added triage me I really want to be triaged. 🚨 This issue needs some love. labels Feb 3, 2020
@BenWhitehead BenWhitehead added priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. and removed 🚨 This issue needs some love. triage me I really want to be triaged. labels Feb 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: firestore Issues related to the googleapis/python-firestore API. priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants