[SQL-CVS] r1516 - SQLObject/branches/0.7-bugfix/sqlobject
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
|
From: <sub...@co...> - 2006-01-16 17:31:19
|
Author: phd
Date: 2006-01-16 10:31:06 -0700 (Mon, 16 Jan 2006)
New Revision: 1516
Modified:
SQLObject/branches/0.7-bugfix/sqlobject/joins.py
Log:
Merged a patch by Jan-Wijbrand Kolman <jw...@in...> for ordering joins with NULLs.
Modified: SQLObject/branches/0.7-bugfix/sqlobject/joins.py
===================================================================
--- SQLObject/branches/0.7-bugfix/sqlobject/joins.py 2006-01-16 17:29:59 UTC (rev 1515)
+++ SQLObject/branches/0.7-bugfix/sqlobject/joins.py 2006-01-16 17:31:06 UTC (rev 1516)
@@ -97,11 +97,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
|