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

Commit time and write results aren't set after the transaction is committed via decorated transactional function #927

Closed
rostyq opened this issue Jul 1, 2024 · 1 comment · Fixed by #977 · May be fixed by #928
Closed
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: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.

Comments

@rostyq
Copy link

rostyq commented Jul 1, 2024

Currently, it is not possible to check transformation results after a successful transaction run in a decorated function without additional read access to firestore database.

Environment details

  • OS type and version: Windows 11
  • Python version: 3.12.0
  • pip version: 24.1.1
  • google-cloud-firestore version: 2.16.1

Steps to reproduce

  1. Implement a @transactional (or @async_transactional) function using any firestore transforms (for example SERVER_TIMESTAMP)
  2. Run a successful Transaction (or AsyncTransaction) in the decorated function
  3. Access commit_time and write_results

Code example

from google.cloud.firestore_v1.client import Client
from google.cloud.firestore_v1.transaction import Transaction, transactional
from google.cloud.firestore_v1.transforms import SERVER_TIMESTAMP

client = Client()

@transactional
def run(t: Transaction):
    t.set(client.document("examples/example"), {"server_timestamp": SERVER_TIMESTAMP})

t = client.transaction()

run(t)

print(t.commit_time)
print(t.write_results)
@product-auto-label product-auto-label bot added the api: firestore Issues related to the googleapis/python-firestore API. label Jul 1, 2024
@daniel-sanche
Copy link
Contributor

I just looked at this, and it seems like commit_time and write_results are inherited from BaseBatch, but not used by the Transaction subclass

It looks like we just need to add these lines from Batch into Transaction._commit. I think it would make sense to make the change

@daniel-sanche daniel-sanche added type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design. priority: p2 Moderately-important priority. Fix may not be included in next release. labels Oct 15, 2024
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: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.
Projects
None yet
3 participants