dtjpnd7517 2014-01-09 11:35
浏览 55
已采纳

我无法查询GQL的2个属性,只有通配符有效

I store comment entity in Datastore and I use Datastore Viewer to see stored data.

I can do following queries

select * from comment    
select __key__ from comment
select Subject from comment
select Comment from comment

But I can't query

select Subject, Comment from comment
// Error: The suggested index for this query is:
//    - kind: comment
//      properties:
//      - name: Comment
//      - name: Subject
select __key__, Subject, Comment from comment
// Error: projections are not supported for the property: __key__

I can't find any reference why it is wrong. These errors does not tell me much.

I have not set any key or index for these entities.

Documentation tells following:

SELECT [DISTINCT] [* | <property list> | __key__]
  [FROM <kind>]
  [WHERE <condition> [AND <condition> ...]]
  [ORDER BY <property> [ASC | DESC] [, <property> [ASC | DESC] ...]]
  [LIMIT [<offset>,]<count>]
  [OFFSET <offset>]

  <property list> := <property> [, <property> ...]
  <condition> := <property> {< | <= | > | >= | = | != } <value>
  <condition> := <property> IN <list>
  <condition> := ANCESTOR IS <entity or key>
  <list> := (<value> [, <value> ...]])

Subject, Comment - is property list and it valid query. But it is not. I created entity from Go code.

  • 写回答

1条回答 默认 最新

  • dqnqpqv3841 2014-01-09 17:17
    关注

    The projection queries come with some limitations. In the projection-doc is mentioned that "Only indexed properties can be projected".

    The first error message shows exactly that the combined index of Subject, Comment doesn't exist yet. You can create the index manually by adding

    - kind: comment
      properties:
      - name: Comment
      - name: Subject
    

    to your index.yaml in your project root folder. Please have a look at the index spec and projection-doc.

    // Error: projections are not supported for the property: __key__
    

    Entity keys are returned by the GetAll method. Don't put them in your projection.

    keys, err := q.GetAll(c, &people)
    

    I can't post more than 2 links yet, so please look for more details in the datastore reference.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?
  • ¥15 matlab(相关搜索:紧聚焦)
  • ¥15 基于51单片机的厨房煤气泄露检测报警系统设计