Yep, docs could be slightly clearer that the - works with the string and the
reversed works in both cases. I'd also probably mention sqlbuilder.DESC, since
it's the parallel to -.

'''
With a string, you can use "-colname" to specify descending order, with a
SQLBuilder (.q) field you can use DESC(Table.q.field). Whether using a string
or field reference, you can use .reversed() on the select object to the same
effect.
'''

Oleg, some added tests to verify for myself that DESC and reversed don't
conflict etc:

Index: test_sorting.py
===================================================================
--- test_sorting.py     (revision 1937)
+++ test_sorting.py     (working copy)
@@ -60,4 +60,14 @@
             ['zoe', 'tim', 'joe', 'joe', 'aj']
      assert firstList(Names.select().orderBy(Names.q.firstName)) == \
             ['aj', 'joe', 'joe', 'tim', 'zoe']
+    assert firstList(Names.select().orderBy('firstName').reversed()) == \
+           ['zoe', 'tim', 'joe', 'joe', 'aj']
+    assert firstList(Names.select().orderBy('-firstName').reversed()) == \
+           ['aj', 'joe', 'joe', 'tim', 'zoe']
+    assert firstList(Names.select().orderBy(DESC(Names.q.firstName))) == \
+           ['zoe', 'tim', 'joe', 'joe', 'aj']
+    assert firstList(Names.select().orderBy(Names.q.firstName).reversed()) ==
\
+           ['zoe', 'tim', 'joe', 'joe', 'aj']
+    assert
firstList(Names.select().orderBy(DESC(Names.q.firstName)).reversed()) == \
+           ['aj', 'joe', 'joe', 'tim', 'zoe']



-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
sqlobject-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss

Reply via email to