【问题标题】:Using a Sort Order Breaks Google App Engine Queries使用排序顺序会中断 Google App Engine 查询
【发布时间】:2010-12-29 04:54:16
【问题描述】:

我的应用引擎查询有问题。当我在没有排序顺序的情况下运行查询时,一切正常:

q = models.Contact.all();
q.filter("location = ", x);
if(cur_search_cursor != None):
   q.with_cursor(cur_search_cursor);
results = q.fetch(limit = max_fetch)
cursor = q.cursor();

上述查询正确返回值。但是,如果我只是在第一行添加排序顺序,则根本不会返回任何内容:

q = models.Contact.all().order('name');
q.filter("location = ", x);
if(cur_search_cursor != None):
   q.with_cursor(cur_search_cursor);
results = q.fetch(limit = max_fetch)
cursor = q.cursor();

没有引发异常,但也没有返回实体。我的代码中有错误吗?还是我必须在我的 index.yaml 文件中做一些特别的事情才能让它工作?

我正在关闭 sqlite 的 dev_server 上尝试这个。我还没有尝试在实际的 GAE 上对其进行测试。

【问题讨论】:

  • 我有点没用过GAE,但是你试过过滤后排序吗?我一直这样做,文档总是按这个顺序做。不过,不确定这是否重要。

标签: python google-app-engine fetch


【解决方案1】:

想通了...“名称”字段是一个 TextProperty。根据文档,TextProperty 不可订购: http://code.google.com/appengine/docs/python/datastore/typesandpropertyclasses.html

浪费了三个小时。

【讨论】:

    猜你喜欢
    • 2012-06-13
    • 2012-07-23
    • 2015-01-23
    • 1970-01-01
    • 2013-06-20
    • 1970-01-01
    • 1970-01-01
    • 2011-01-15
    • 1970-01-01
    相关资源
    最近更新 更多