-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Closed
Labels
🚨This issue needs some love.This issue needs some love.api: datastoreIssues related to the Datastore API.Issues related to the Datastore API.triage meI really want to be triaged.I really want to be triaged.
Description
Proposed fix:
Do not ask for dataset_id
in the constructor and instead gather it from the keys and queries used in the transaction.
This may require implementing #495 and will require removing the self.begin()
call from Transaction.__enter__
. (Can't begin until a query or entity is encountered.)
Title was: "Transaction does not rollback correctly when multiple datasets involved"
Witness the following code:
>>> from gcloud import datastore
>>> cnxn = datastore.get_connection()
>>> dataset1 = cnxn.dataset('PROJ1')
>>> dataset2 = cnxn.dataset('PROJ2')
>>> e1 = dataset1.entity('foo')
>>> e2 = dataset2.entity('foo')
>>> e1['bar'] = e2['bar'] = 0
>>> e1.save()
<Entity[{'kind': u'foo', 'id': 5686683802533888L}] {'bar': 0}>
>>> e2.save()
<Entity[{'kind': u'foo', 'id': 5659313586569216L}] {'bar': 0}>
>>> with dataset1.transaction():
... e1.delete()
... e2.delete()
...
>>> e1_still = dataset1.get_entity(e1.key())
>>> e1_still is None
True
>>> e2_still = dataset2.get_entity(e2.key())
>>> e2_still
<Entity[{'kind': u'foo', 'id': 5659313586569216L}] {u'bar': 0L}>
Metadata
Metadata
Assignees
Labels
🚨This issue needs some love.This issue needs some love.api: datastoreIssues related to the Datastore API.Issues related to the Datastore API.triage meI really want to be triaged.I really want to be triaged.