[SQL-CVS] r1515 - SQLObject/trunk/sqlobject
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
|
From: <sub...@co...> - 2006-01-16 17:30:30
|
Author: phd
Date: 2006-01-16 10:29:59 -0700 (Mon, 16 Jan 2006)
New Revision: 1515
Modified:
SQLObject/trunk/sqlobject/joins.py
Log:
A patch by Jan-Wijbrand Kolman <jw...@in...> for ordering joins with NULLs.
Modified: SQLObject/trunk/sqlobject/joins.py
===================================================================
--- SQLObject/trunk/sqlobject/joins.py 2006-01-16 16:58:58 UTC (rev 1514)
+++ SQLObject/trunk/sqlobject/joins.py 2006-01-16 17:29:59 UTC (rev 1515)
@@ -99,11 +99,22 @@
# @@: but we don't handle more complex expressions for orderings
if orderBy.startswith('-'):
orderBy = orderBy[1:]
- def cmper(a, b, attr=orderBy):
- return cmp(getattr(b, attr), getattr(a, attr))
+ reverse = True
else:
- def cmper(a, b, attr=orderBy):
- return cmp(getattr(a, attr), getattr(b, attr))
+ reverse = False
+
+ def cmper(a, b, attr=orderBy, rev=reverse):
+ a = getattr(a, attr)
+ b = getattr(b, attr)
+ if rev:
+ a, b = b, a
+ if a is None:
+ if b is None:
+ return 0
+ return -1
+ if b is None:
+ return 1
+ return cmp(a, b)
return cmper
# This is a one-to-many
|