本文介绍了Appengine过滤器不等式和排序失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想我在这里忽略了一些简单的东西,我无法想象这是做不到的。



我想用日期时间属性过滤,然后点排名整数属性的结果。当我尝试这样做时:

  query.filter(submitted> =thisweek).order(ranking) 

我收到以下内容:

  BadArgumentError:如果为此查询指定,则第一个排序属性必须与不等过滤器属性相同;收到排名,预计提交

咦?我缺少什么?



感谢。

解决方案

数据存储isn不能够通过除了不等式中使用的属性之外的任何属性来排序包含不等式的查询。

这通常可以通过添加可以用相等性过滤的属性来解决;在这种情况下,可能需要一个Boolean属性来跟踪实体是否来自当前周,并在每周结束时更新所有实体。


I think I'm overlooking something simple here, I can't imagine this is impossible to do.

I want to filter by a datetime attribute and then order the result by a ranking integer attribute. When I try to do this:

query.filter("submitted >=" thisweek).order("ranking")

I get the following:

BadArgumentError: First ordering property must be the same as inequality filter property, if specified for this query; received ranking, expected submitted

Huh? What am I missing?

Thanks.

解决方案

The datastore isn't capable of ordering a query that contains an inequality by any property other than the one used in the inequality.

This can often be worked around by adding a property that can be filtered with an equality; in this case, it may be possible to have a BooleanProperty tracking whether an entity is from the current week, and update it for all entities at the end of each week.

这篇关于Appengine过滤器不等式和排序失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-23 05:23