不支持 GQL DISTINCT 祖先查询吗?

问题描述 投票:0回答:1

这有效:

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

Python 的 NDB 不支持 GQL DISTINCT 祖先查询,还是这是一个错误?

python google-app-engine google-cloud-datastore app-engine-ndb gql
1个回答
2
投票

这似乎是有意的行为。根据here的答案,问题来自于使用不同的投影查询。因为它仅用于属性而不是祖先,如此处所示

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

© www.soinside.com 2019 - 2024. All rights reserved.