Re: [SQLObject] Reversed ordering, again
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
From: Ian B. <ia...@co...> - 2003-11-12 17:31:18
|
On Nov 11, 2003, at 12:11 AM, Randall Randall wrote: > For Googlers: > > In SQLObject 0.5, using psycopg, you can't reverse the > orderBy of the column 'id'. You can reverse any column > you explicitly specified by the name you gave for the > column. So this: > > MyClass.select().reversed() > > doesn't actually work, but you can work around it by > including another autoincrement column, or a DateTime > column that uses the SQLBuilder.func.NOW() function > as its default. If you're like me, you use that in > most objects anyway, just in case you might want to > track creation times later. :) > > In the documentation for 0.5, this paragraph: > > """ > You can use the keyword arguments orderBy and groupBy to > create ORDER BY and GROUP BY in the select statements: > orderBy takes a string, which should be the database > name of the column, or a column in the form Person.q.firstName; > groupBy is similar. Both accept lists or tuples of arguments. > You can use "-colname" to specify descending order, or call > MyClass.select().reversed(). > """ > > is wrong as written, and should be > > """ > You can use the keyword arguments orderBy and groupBy to > create ORDER BY and GROUP BY in the select statements: > orderBy takes a string, which should be the attribute > name, not the database column name. Unlike in the select() > method, you cannot use columns in the form Person.q.firstName > here; [...] You can use "-attributeName" to specify > descending order; MyClass.select().reversed() is not > implemented (or broken) and returns None. > """ > > I didn't test groupBy, so omitted that part of this > paragraph. > > It may be that these are considered bugs, or simply weren't > yet implemented as documented; I don't know. The lack of > response the other day suggests the latter. :) I think it was one of those I-meant-to-look-at-it-more-closely-when-I-had-some-time-then-I-forgot situations. There was just a missing "return" in reversed(). It should be fixed now in CVS. -- Ian Bicking | ia...@co... | http://blog.ianbicking.org |