GQL Query with __key__ in List of KEYs
- by bossylobster
In the GQL reference [1], 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?
[1] http://code.google.com/appengine/docs/python/datastore/gqlreference.html
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.