Note that there are some explanatory texts on larger screens.

plurals
  1. POGQL Query with __key__ in List of KEYs
    text
    copied!<p>In the <a href="http://code.google.com/appengine/docs/python/datastore/gqlreference.html" rel="nofollow">GQL reference</a>, it is encouraged to use the <code>IN</code> keyword with a list of values, and to construct a Key from hand the GQL query</p> <pre><code>SELECT * FROM MyModel WHERE __key__ = KEY('MyModel', 'my_model_key') </code></pre> <p>will succeed. However, using the code you would expect to work:</p> <pre><code>SELECT * FROM MyModel WHERE __key__ IN (KEY('MyModel', 'my_model_key1'), KEY('MyModel', 'my_model_key2')) </code></pre> <p>in the Datastore Viewer, there is a complaint of "Invalid GQL query string."</p> <p>What is the correct way to format such a query?</p> <p>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. <code>:1</code> or <code>:email</code>) or an int, float, string, boolean or null literal are acceptable list entries.</p> <p><strong>SECOND UPDATE: I fixed the bug and it is now possible to perform such queries. Fix can be found in Google Code Hosting <a href="http://code.google.com/p/googleappengine/source/diff?spec=svn241&amp;r=241&amp;format=side&amp;path=/trunk/python/google/appengine/ext/gql/__init__.py&amp;old_path=/trunk/python/google/appengine/ext/gql/__init__.py" rel="nofollow">diff</a>.</strong></p> <p>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.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload