Agnes Kang
Agnes Kang

Reputation: 15

GQL IN operator error

I encounter an appengine error from a GQL query with "IN" operator. my query is as follows:

SELECT * FROM ratings WHERE rating >= 0.0 AND cat = 1 AND pid IN(44,14)

the error message is:

PHP Fatal error:  Uncaught exception 'google\appengine\runtime\ApplicationError' with message 'Encountered "IN" at line 1, column 84.
Was expecting one of:
    "contains" ...
    "has" ...
    "is" ...
    "=" ...
    "<" ...
    "<=" ...
    ">" ...
    ">=" ...
    "." ...
    "(" ...
    ' in /base/data/home/runtimes/php/sdk/google/appengine/runtime/RealApiProxy.php:53

I put my query in datastore admin console It works without any error and showed the exactly result. What's wrong??

Upvotes: 0

Views: 3754

Answers (1)

Tim Hoffman
Tim Hoffman

Reputation: 12986

You are confused about what the IN operator does. It can not do what you want.

Please read the docs on cloud datastore https://cloud.google.com/datastore/docs/apis/gql/gql_reference

Notice that the operator = is another name for the IN and CONTAINS operators. For example, <value> = <property-name> is the same as <value> IN <property-name>, and <property-name> = <value> is the same as <property-name> CONTAINS <value>. Also <property-name> IS NULL is the same as <property-name> = NULL.

Upvotes: 2

Related Questions