Re: [SQLObject] orderBy table.q.attribute
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
From: Ian B. <ia...@co...> - 2004-04-23 17:04:41
|
Oleg Broytmann wrote: > On Fri, Apr 23, 2004 at 11:18:15AM -0500, Ian Bicking wrote: > >>"-registrationTime"? Both should work, but maybe they don't. > > > Traceback (most recent call last): > [snip] > File "/usr/local/lib/python2.3/site-packages/SQLObject/DBConnection.py", line 168, in _iterSelect > cursor.execute(query) > ProgrammingError: ERROR: Non-integer constant in ORDER BY > > SELECT ... ORDER BY 'registrationTime' DESC > > Both does not. DB is Postgres. Ah... I found the bug, in _mungeOrderBy; which should look like: def _mungeOrderBy(self, orderBy): if isinstance(orderBy, str) and orderBy.startswith('-'): orderBy = orderBy[1:] desc = True else: desc = False if isinstance(orderBy, (str, unicode)): if self.sourceClass._SO_columnDict.has_key(orderBy): val = self.sourceClass._SO_columnDict[orderBy].dbName if desc: return '-' + val else: return val else: if desc: return '-' + orderBy else: return orderBy else: return orderBy |