开发者

Using a Sort Order Breaks Google App Engine Queries

I'm having a problem with my ap开发者_如何学Gop-engine queries. When I run my query without sort order, everything works just fine:

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();

The above query properly returns values. However, if I simply add a sort order to the first line, nothing is returned at all:

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();

No exception is raised, but no entities are returned either. Is there a bug in my code? Or do I have to do something special in my index.yaml file to get this to work?

I'm trying this on the dev_server with sqlite turned off. I haven't tried testing it on the actual GAE.


Figured it out... the 'name' field is a TextProperty. A TextProperty is not orderable, as per the documentation: http://code.google.com/appengine/docs/python/datastore/typesandpropertyclasses.html

That was a waste of three hours.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜