Is there some way of reliably using the orderBy parameter with
something other than a simple column, like a SQL function?  Right now
I do something like the following (where sbtable is
sqlobject.sqlbuilder.table):

class Contact (SQLObject):
    class sqlmeta:
        defaultOrder = \
               func.CONCAT(func.IFNULL(sbTable.contacts.last_name, ""),
                           func.IFNULL(sbTable.contacts.first_name, ""),
                           func.IFNULL(sbTable.contacts.organization, ""))

While this works for queries on this table alone, as soon as I try
refer to the table from another SQLObject class via a MultipleJoin
with no orderBy parameter I get an AttributeError (SQLCall instance
has no attribute '__getitem__'  in sqlobject/joins.py:100).  Setting
orderBy=None in the MultipleJoin declaration clears it up, but of
course result ordering is hosed at that point.

Are SQL functions not allowed as orderBy parameters in all cases?
Does anyone have any other ideas?

Thanks,
Barry

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
sqlobject-discuss mailing list
sqlobject-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss

Reply via email to