On Tue, 2007-04-24 at 15:56 +0400, Oleg Broytmann wrote:
> On Tue, Apr 24, 2007 at 07:49:14AM -0400, David Turner wrote:
> > I can't figure out how to make SQLObject order by multiple columns. Is
> > this possible? It seems like Table.select(query).orderBy("col1 asc,
> > col2 desc") or something ought to just work, but SQLObject rejects it.
> > Any ideas?
>
> orderBy() requires a list:
>
> Table.select(query).orderBy(["col1 asc", "col2 desc"])
> Table.select(query).orderBy([Table.q.col1, DESC(Table.q.col2)])
I get errors when I try the first of these. I'm using svn SQLObject.
Test case:
from sqlobject import *
from sqlobject.tests.dbtest import *
########################################
## order by list of strings
########################################
class Tab(SQLObject):
col1 = StringCol()
col2 = IntCol()
def test_multiple_order():
setupClass(Tab)
#works
sresults = Tab.select().orderBy(["-col1"])
tabs = list(sresults)
#fails
sresults = Tab.select().orderBy(["col1 desc"])
tabs = list(sresults)
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
sqlobject-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss