Python 是否不支持GQL不同祖先查询?

Python 是否不支持GQL不同祖先查询?,python,google-app-engine,google-cloud-datastore,app-engine-ndb,gql,Python,Google App Engine,Google Cloud Datastore,App Engine Ndb,Gql,这项工作: from google.appengine.ext import ndb query = ndb.gql("SELECT distinct id from Pocket") query.fetch() 这也适用于: query = ndb.gql("SELECT id from Pocket where ancestor is :1") query = query.bind(u.key) 这会引发一个错误: query = ndb.gql("SELECT distinct id

这项工作:

from google.appengine.ext import ndb
query = ndb.gql("SELECT distinct id from Pocket")
query.fetch()
这也适用于:

query = ndb.gql("SELECT id from Pocket where ancestor is :1")
query = query.bind(u.key)
这会引发一个错误:

query = ndb.gql("SELECT distinct id from Pocket where ancestor is :1")
query = query.bind(u.key)
错误是:

BadQueryError: Parse Error: Identifier is a reserved keyword at symbol ancestor

NDB for python是否不支持GQL不同祖先查询,或者这是一个bug

这似乎是有意的行为。根据答案,问题来自于将distinct与投影查询一起使用。因为它仅用于属性,而不是祖先,根据[1]:

“可选的DISTINCT(实验性)子句指定在结果集中只返回完全唯一的结果。这将只返回具有与所投影属性相同值的实体的第一个结果。”


[1]

stackoverflow文章的链接在哪里?我现在明白你的意思了。。。当您使用DISTINCT时,
\uuuuuuuuuu key\uuuuuuuu
字段不会返回,并且如果没有
\uuuuuuuuuu key\uuuuuuuuu
,则对API没有意义。不管怎样,错误消息都没有任何帮助。