Repository navigation
runQuery doesn't run inside transaction #905
Copy link
Copy link
Closed
Labels
api: datastoreIssues related to the Datastore API.Issues related to the Datastore API.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
Activity
- addedtype: 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.api: datastoreIssues related to the Datastore API.Issues related to the Datastore API.
on Oct 5, 2015 I think it will work as intended. When the API request is made, it goes through this method: https://github.com/GoogleCloudPlatform/gcloud-node/blob/69046d383af6bf67a316739c66650601228abc8a/lib/datastore/request.js#L759:
DatastoreRequest.prototype.makeReq_ = function(method, body, callback) { // ... if (method === 'lookup' && this.id) { body.read_options = body.read_options || {}; body.read_options.transaction = this.id; } // ...
this.idis set to the transaction ID when using a Transaction object.That's if the method is 'lookup'. But what if the method is 'runQuery'?
Ah, woops. So I think we just need
this.id && (method === 'lookup' || method === 'runQuery').- added a commit that references this issue
on Nov 11, 2022 - added 6 commits that reference this issue
on Jan 27, 2026 - added a commit that references this issue
on Jan 28, 2026 - added a commit that references this issue
on Feb 17, 2026 - added 2 commits that reference this issue
on Feb 24, 2026 - added a commit that references this issue
on Mar 5, 2026 - added a commit that references this issue
on Mar 18, 2026
Metadata
Metadata
Assignees
Labels
api: datastoreIssues related to the Datastore API.Issues related to the Datastore API.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.
Sorry if this isn't right, I only noticed it through inspection.
It looks like Transaction extends from DatastoreRequest, which means it gets a
runQuerymethod. However, it doesn't look like it overrides it. This means a user who thinks they are running a query in the transaction is actually going to get inconsistent results.