【问题标题】:GQL IN operator errorGQL IN 运算符错误
【发布时间】:2015-12-09 05:21:01
【问题描述】:

我在使用“IN”运算符的 GQL 查询中遇到 appengine 错误。我的查询如下:

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

错误信息是:

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

我将查询放在数据存储管理控制台中,它可以正常工作并显示准确的结果。 怎么了??

【问题讨论】:

    标签: google-app-engine google-cloud-datastore gql


    【解决方案1】:

    您对 IN 运算符的作用感到困惑。它不能做你想做的。

    请阅读云数据存储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.

    【讨论】:

    • GQL 不支持 OR 运算符和支持 IN 运算符不同。如何将带有 IN 运算符的 SQL 命令转换为 GQL?否则,我应该分成几个简单的GQL选择操作来得到我想要的?
    • 您的选项是执行 2 次查询并在之后合并结果,或者查看如何重组 PID 属性,例如可能是一个范围。在不了解数据结构和意图的情况下,很难提出策略建议。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-07-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-05-08
    • 2021-10-17
    • 1970-01-01
    相关资源
    最近更新 更多