Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7748433
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T10:47:03+00:00 2026-06-01T10:47:03+00:00

In the GQL reference , it is encouraged to use the IN keyword with

  • 0

In the GQL reference, it is encouraged to use the IN keyword with a list of values, and to construct a Key from hand the GQL query

SELECT * FROM MyModel WHERE __key__ = KEY('MyModel', 'my_model_key')

will succeed. However, using the code you would expect to work:

SELECT * FROM MyModel WHERE __key__ IN (KEY('MyModel', 'my_model_key1'),
                                        KEY('MyModel', 'my_model_key2'))

in the Datastore Viewer, there is a complaint of “Invalid GQL query string.”

What is the correct way to format such a query?

UPDATE: This is not possible to do with the current SDK. As I note in my comment, when using a list, only a reference (e.g. :1 or :email) or an int, float, string, boolean or null literal are acceptable list entries.

SECOND UPDATE: I fixed the bug and it is now possible to perform such queries. Fix can be found in Google Code Hosting diff.

PS I know there are more efficient ways to do this in Python (without constructing a GQL query) and using the remote_api, but each call to the remote_api counts against quota. In an environment where quota is not (necessarily) free, quick and dirty queries are very helpful.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T10:47:05+00:00Added an answer on June 1, 2026 at 10:47 am

    After the fix was implemented, the code snippet from the original post will suffice:

    SELECT * FROM MyModel WHERE __key__ IN (KEY('MyModel', 'my_model_key1'),
                                            KEY('MyModel', 'my_model_key2'))
    

    PS I realized my comment on the original post may not be sufficiently clear as an answer to future viewers.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How to construct a GQL query using server side admin datastore viewer, a one
How should I create a GQL query that returns the nearest entities (from my
How can I select only objects with null values in GQL. I have a
This is my gql code: data = db.GqlQuery(SELECT * FROM Playlist + WHERE tags
How to search in the GQL Viewer in appengine dashboard by key? I use
I'm trying to write a GQL query that returns N random records of a
I'd like to create a gql query through my browser dashboard to easily look
I would like to order entities by ancestor, GQL reference only mentions properties in
I want to build GQL query to get an object using its numeric id.
Is there some way to GROUP BY in App Engine, via GQL or Query

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.