db(query).select(orderby='Field(id, %s)' % ', '.join(str(id) for id in list_of_ids))
db(query).select().sort(lambda r: list_of_ids.index(r.id))
Thanks Anthony, I will go with the first option and guess how to adapt it to postgress too.
Greetings.
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups "web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to web2py+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
def make_orderby(idlist):
result="CASE"
for i, el in enumerate(idlist):
result += " WHEN id = %d THEN '%d' " % (el, i)
result += " ELSE id END ASC"
return result
Thanks Leonel, that sounds interesting, I will take a look.
Greetings.