我需要在 GAE 中进行一个查询,该查询返回不包含 null 的行,这意味着已满足
SELECT * FROM Feedback WHERE text =! None
Nul
,也不起作用。
它不起作用...那么我应该如何编写这个查询呢?
SELECT * FROM Feedback WHERE text =! None
Nul
, doesn't work either.
It doesn't work... So how should I write this query?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
来自 GAE 文档:
无法查询缺少给定属性的实体。一种替代方法是创建默认值为 None 的固定(建模)属性,然后为以 None 作为属性值的实体创建过滤器。
您可以通过以下方式获得相同的结果:
这将返回文本字段不是 None 的 Feedback 对象列表。尽管这确实会产生首先加载所有反馈对象的额外开销。
From GAE documentation:
It is not possible to query for entities that are missing a given property. One alternative is to create a fixed (modeled) property with a default value of None, then create a filter for entities with None as the property value.
You could achieve the same results by:
This will return a list of Feedback objects where the text field is not None. Although this does have the extra overhead of loading all Feedback objects first.
具有 null 的实体不包含在该查询的索引中。您可能想实际存储一个虚拟值,例如“None”/“Null”。 (参考http://code.google.com/appengine/ docs/python/datastore/queries.html#Restrictions_on_Queries )
Entities with null are not included in the index for that query. You may want to actually store a dummy value like 'None'/'Null' instead. (Ref. http://code.google.com/appengine/docs/python/datastore/queries.html#Restrictions_on_Queries )
试试这个:
在此处找到参考。请注意,它没有记录,所以可能不是一个很好的解决方案。
Try this:
Found reference here. Note that it's undocumented, so maybe not a very good solution.