Author: reinhard
Date: 2010-05-27 09:13:42 -0500 (Thu, 27 May 2010)
New Revision: 10188

Modified:
   trunk/gnue-appserver/
   trunk/gnue-appserver/src/data.py
Log:
Fixed sorting of None values when manually sorting records.



Property changes on: trunk/gnue-appserver
___________________________________________________________________
Name: bzr:revision-info
   - timestamp: 2010-05-05 10:38:17.378999949 +0200
committer: Reinhard Müller <reinhard.muel...@bytewise.at>
properties: 
        branch-nick: appserver

   + timestamp: 2010-05-27 16:10:18.536999941 +0200
committer: Reinhard Müller <reinhard.muel...@bytewise.at>
properties: 
        branch-nick: appserver

Name: bzr:file-ids
   - setup.py   
2...@3a364389-8fce-0310-8f11-cc363fde16c7:trunk%2Fgnue-appserver:setup.py

   + src/data.py        
5...@3a364389-8fce-0310-8f11-cc363fde16c7:trunk%2Fgnue-appserver:src%2Fdata.py

Name: bzr:revision-id:v4
   - 1201 reinhard.muel...@bytewise.at-20100505083817-crajf6ww0qv2qjjv

   + 1201 reinhard.muel...@bytewise.at-20100505083817-crajf6ww0qv2qjjv
1202 reinhard.muel...@bytewise.at-20100527141018-165rctpy1o6glbss

Name: bzr:text-parents
   - setup.py   
svn-v3-single1-dHJ1bmsvZ251ZS1hcHBzZXJ2ZXI.:3a364389-8fce-0310-8f11-cc363fde16c7:trunk%2Fgnue-appserver:10078

   + src/data.py        
svn-v3-single1-dHJ1bmsvZ251ZS1hcHBzZXJ2ZXI.:3a364389-8fce-0310-8f11-cc363fde16c7:trunk%2Fgnue-appserver:9953


Modified: trunk/gnue-appserver/src/data.py
===================================================================
--- trunk/gnue-appserver/src/data.py    2010-05-26 11:19:44 UTC (rev 10187)
+++ trunk/gnue-appserver/src/data.py    2010-05-27 14:13:42 UTC (rev 10188)
@@ -1922,15 +1922,26 @@
                "'%(self)s', '%(other)s'") \
             % {'self': self.sorting [ix], 'other': other.sorting [ix]}
 
+      if left is None and right is None:
+        continue
+
       noneOpt = self.nullFirstAsc
       if descending:
         (left, right) = (right, left)
-        noneOpt = not self.nullFirstDsc
+        noneOpt = not noneOpt
 
-      if None in [left, right]:
-        if not noneOpt:
-          (left, right) = (right, left)
-        result = cmp (left, right)
+      # If any of the items is None, set the result explicitly, since some
+      # types (e.g. datetime types) can't cmp to None.
+      if left is None:
+        if noneOpt:
+          result = 1
+        else:
+          result = -1
+      elif right is None:
+        if noneOpt:
+          result = -1
+        else:
+          result = 1
       else:
         result = cmp (left, right)
 


_______________________________________________
commit-gnue mailing list
commit-gnue@gnu.org
http://lists.gnu.org/mailman/listinfo/commit-gnue

Reply via email to