On Dec 31, 2011, at 8:46 AM, sungchi wrote: > now=time.time() > sorts={ > 'hot':~db.news.hotness, > 'score:~db.news.score, > 'new':~db.news.post_time} > orderby=sorts[sort] > limitby=(50,101) > news = db(db.news.post_time>(now-25922000.0)).select(limitby=limitby, > orderby=orderby) > > > Traceback (most recent call last): > File "/Users/web2py/gluon/restricted.py", line 204, in restricted > exec ccode in environment > File "/Users/web2py/applications/feed9/controllers/default.py", line > 352, in <module> > File "/User/web2py/gluon/globals.py", line 162, in <lambda> > self._caller = lambda f: f() > File "/Users/web2py/applications/feed9/controllers/default.py", line > 123, in index > > news=db(db.news.post_time>(now-2592000.0)).select(limitby=limitby,orderby=orderby) > File "/Users/web2py/gluon/dal.py", line 6330, in select > return self.db._adapter.select(self.query,fields,attributes) > File "/Users/web2py/gluon/dal.py", line 3463, in select > (items, tablename, fields) = > self.select_raw(query,fields,attributes) > File "/Users/sungchi9/Dropbox/python/web2py/gluon/dal.py", line > 3458, in select_raw > items = items.fetch(limit, offset=offset) > File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/ > GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/ > google/appengine/ext/db/__init__.py", line 2084, in fetch > return list(self.run(limit=limit, offset=offset, **kwargs)) > File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/ > GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/ > google/appengine/ext/db/__init__.py", line 2001, in run > raw_query = self._get_query() > File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/ > GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/ > google/appengine/ext/db/__init__.py", line 2357, in _get_query > query.Order(*self.__orderings) > File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/ > GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/ > google/appengine/api/datastore.py", line 1398, in Order > (orderings[0][0], self.__inequality_prop)) > BadArgumentError: First ordering property must be the same as > inequality filter property, if specified for this query; received > score, expected post_time > > > > what's wrong? why not post_time filter with orderby argument?
http://code.google.com/appengine/docs/java/datastore/queries.html#Restrictions_on_Queries > If a query has both a filter with an inequality comparison and one or more > sort orders, the query must include a sort order for the property used in the > inequality, and the sort order must appear before sort orders on other > properties. Just sort the result in code.