Is only first argument available for "ordering factor" with GAE?

29 views
Skip to first unread message

JungHyun Kim

unread,
Aug 20, 2012, 10:20:05 AM8/20/12
to web...@googlegroups.com
Hello everyone!

I have question about order by option with GAE. 
This code works well on my local (not GAE test server), but has problem on google app engine. (even on the GAE local test server)

I filtered messages which has end_time after now, and tried to sort them by reg_time. 

    messages = db(db.mibmessage.end_time >= datetime.now()).select(orderby=~db.mibmessage.reg_time)

But there was an internal error.

<class 'google.appengine.api.datastore_errors.BadArgumentError'> First ordering property must be the same as inequality filter property, if specified for this query; received reg_time, expected end_time

Is it GAE's limitation?

Should I sort them by myself ?



Jonathan Lundell

unread,
Aug 20, 2012, 10:25:49 AM8/20/12
to web...@googlegroups.com
Yes, a limitation of how they implement their SQL wrapper, apparently.


Should I sort them by myself ?


I think you're stuck with it, yes.

JungHyun Kim

unread,
Aug 20, 2012, 10:38:08 AM8/20/12
to web...@googlegroups.com
Thank you Lundell!

If it is a limitation, I don't need to argue with it.
You saved me!

2012년 8월 20일 월요일 오후 11시 25분 49초 UTC+9, Jonathan Lundell 님의 말:

howesc

unread,
Aug 20, 2012, 6:55:17 PM8/20/12
to web...@googlegroups.com
you may also do orderby=db.mibmessage.end_time|~db.mibmessage.reg_time  - that is a legal sort on GAE, it may not be what you want though.

you know about select().sort(lambda r:...) right?  i use that on GAE to get around extra indexes and illegal sorts. :)

JungHyun Kim

unread,
Aug 20, 2012, 10:47:11 PM8/20/12
to web...@googlegroups.com
Thank you howesc :)

As you said, I used select().sort(lambda message:message.reg_time,reverse=True)





2012년 8월 21일 화요일 오전 7시 55분 17초 UTC+9, howesc 님의 말:
Reply all
Reply to author
Forward
0 new messages