GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — datastore: can not runQuery in a transaction · Issue #1138 · googleapis/google-cloud-node

datastore: can not runQuery in a transaction #1138

New issue
Copy link
New issue
Copy link
Closed
Closed
datastore: can not runQuery in a transaction#1138
Copy link
Assignees
stephenplusplus
Labels
api: datastoreIssues related to the Datastore API.type: questionRequest for information or clarification. Not an issue.

Description

@jasonswearingen
jasonswearingen
opened on Feb 29, 2016
Issue body actions

hello is running a query in a transaction supposed to be supported? I get errors when doing so (invalid response), while running a query outside of transactions works fine, and reading+writing inside a transaction also works.

I'm trying to do a query with a filter "email ="

sorry I can't provide you code, I do my datastore operations via a self-rolled orm.

Activity

  1. stephenplusplus
    added
    api: datastoreIssues related to the Datastore API.
    on Feb 29, 2016
  2. stephenplusplus commented on Feb 29, 2016

    @stephenplusplus
    stephenplusplus
    on Feb 29, 2016
    Contributor
    More actions

    It should work, as far as I know. What version of gcloud are you running? I'll try to reproduce.

  3. jasonswearingen commented on Feb 29, 2016

    @jasonswearingen
    jasonswearingen
    on Feb 29, 2016
    Author
    More actions

    thanks Stephen, i'm using 0.27, since it's supposed to work, i'll do a repro and post it here in a few min.

  4. jasonswearingen commented on Feb 29, 2016

    @jasonswearingen
    jasonswearingen
    on Feb 29, 2016
    Author
    More actions

    here is my repro code:

    
                console.log("################## running datastore transaction query test");
                let key = dataset.key(["test", 123]);
    
                dataset.upsert({
                    key: key,
                    data: { email: "[email protected]" }
                }, (err, upsertResponse) => {
    
                    if (err != null) {
                        console.log("!!!!!!!!!!!!!!!!!!!!!!!! dataset.upsert err", err.message);
                        throw err;
                    }
                    console.log("################## upsert complete");
    
                    dataset.runInTransaction((transaction, done) => {
    
                        let query = dataset.createQuery("test");
                        query.filter("email =", "[email protected]");
    
                        transaction.runQuery(query, (err, entities) => {
    
                            if (err != null) {
                                console.log("!!!!!!!!!!!!!!!!!!!!!!!! transaction.runQuery err",err.message);
                                throw err;
                            }
    
                            console.log("################## transaction.runQuery complete");
                            for (let i = 0; i < entities.length; i++) {
                                let current = entities[i];
                                console.log("################## entity " + i, current.key.path.join(), JSON.stringify(current.data));
                            }
    
                        });
    
                    }, (err, transactionResponse) => {
                        if (err != null) {
                            console.log("!!!!!!!!!!!!!!!!!!!!!!!! transaction.runInTransaction err", err.message);
                            throw err;
                        }
                        console.log("################## transaction.runInTransaction complete");
    
                    });
    
    
                });
    

    and here is my console output:

    ################## running datastore transaction query test
    ################## upsert complete
    !!!!!!!!!!!!!!!!!!!!!!!! transaction.runQuery err Bad Request
    ApiError: Bad Request
        at new util.ApiError (C:\repos\stage3\nlib\node_modules\gcloud\lib\common\util.js:92:10)
        at Object.parseHttpRespMessage (C:\repos\stage3\nlib\node_modules\gcloud\lib\common\util.js:134:33)
        at Request._callback (C:\repos\stage3\nlib\node_modules\gcloud\lib\datastore\request.js:813:31)
        at Request.self.callback (C:\repos\stage3\nlib\node_modules\request\request.js:199:22)
        at emitTwo (events.js:87:13)
        at Request.emit (events.js:172:7)
        at Request.<anonymous> (C:\repos\stage3\nlib\node_modules\request\request.js:1036:10)
        at emitOne (events.js:82:20)
        at Request.emit (events.js:169:7)
        at IncomingMessage.<anonymous> (C:\repos\stage3\nlib\node_modules\request\request.js:963:12)
        at emitNone (events.js:72:20)
        at IncomingMessage.emit (events.js:166:7)
        at endReadableNT (_stream_readable.js:905:12)
        at nextTickCallbackWith2Args (node.js:474:9)
        at process._tickCallback (node.js:388:17)
    [ERROR] 07:59:27 ApiError
    
  5. stephenplusplus commented on Feb 29, 2016

    @stephenplusplus
    stephenplusplus
    on Feb 29, 2016
    Contributor
    More actions

    I ran this test with v0.28, which reports more helpful errors. Try updating just to make the experience a little better-- it will require one change:

    -query.filter("email =", "[email protected]");
    +query.filter("email", "[email protected]");

    Anyway, because I upgraded and received the better error reporting, what I got was:

    ApiError: Bad Request - queries inside transactions must have ancestors
    

    There's a description of what that means here: https://cloud.google.com/appengine/docs/python/datastore/queries#queries_inside_transactions_must_include_ancestor_filters

    See if with this information you can produce the desired results. If not, we can call for some more help :)

  6. jasonswearingen commented on Feb 29, 2016

    @jasonswearingen
    jasonswearingen
    on Feb 29, 2016
    Author
    More actions

    ok thanks, i don't know much about ancestors (have deliberately avoided them), so pretty sure none of my data uses them, so it looks like I can't query in transactions in my use-case. It seems ok though (and probably better): I worked around this by running my query first, and then run the transaction.

  7. stephenplusplus commented on Feb 29, 2016

    @stephenplusplus
    stephenplusplus
    on Feb 29, 2016
    Contributor
    More actions

    Cool! Let me know if there are any other questions or issues with this approach.

  8. stephenplusplus
    closed this as completedon Feb 29, 2016
  9. stephenplusplus
    added
    type: questionRequest for information or clarification. Not an issue.
    on Feb 29, 2016
  10. JustinBeckwith
    assigned
    stephenplusplus
    on Feb 1, 2021
  11. miguelvelezsa
    added a commit that references this issue on Jul 23, 2025

    test: Add integration test for rest client stream against showcase (#…

    8052ab9
  12. gcf-owl-bot
    added a commit that references this issue on Jan 7, 2026

    feat: Update Compute Engine v1beta API to revision 20251210 (#1138)

    3b0135d
  13. quirogas
    added a commit that references this issue on Jan 8, 2026

    feat: Update Compute Engine v1beta API to revision 20251210 (#1138)

    954125b
  14. miguelvelezsa
    added a commit that references this issue on Jan 28, 2026

    fix: simplify logic for HTTP/1.1 REST fallback option (#1138)

    e16477a
  15. sofisl
    added 2 commits that reference this issue on Feb 3, 2026

    chore(deps): update dependency linkinator to v4 (#1138)

    73fa3a1

    fix: simplify logic for HTTP/1.1 REST fallback option (#1138)

    e35a107
  16. sofisl
    added a commit that references this issue on Feb 17, 2026

    fix: simplify logic for HTTP/1.1 REST fallback option (#1138)

    e79f073
  17. thiyaguk09
    added a commit that references this issue on Mar 18, 2026

    chore(samples): region tag for post policy sample (googleapis#1138)

    ccf5b75
  18. GautamSharda
    added 2 commits that reference this issue on Mar 23, 2026

    fix: fixed the closed client test (#1138)

    97ba589

    fix: fixed the closed client test (#1138)

    de772a1
  19. shivanee-p
    added a commit that references this issue on Mar 27, 2026

    fix: fixed the closed client test (#1138)

    45a154d
  20. thiyaguk09
    added a commit that references this issue on May 5, 2026

    fix: fixed the closed client test (googleapis#1138)

    225e79b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @stephenplusplus
    stephenplusplus

Labels

api: datastoreIssues related to the Datastore API.type: questionRequest for information or clarification. Not an issue.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.