fix ordering
authorjlaine <jlaine@e071eeec-0327-468d-9b6a-08194a12b294>
Mon, 31 May 2010 18:07:06 +0000 (18:07 +0000)
committerjlaine <jlaine@e071eeec-0327-468d-9b6a-08194a12b294>
Mon, 31 May 2010 18:07:06 +0000 (18:07 +0000)
git-svn-id: https://svn.bolloretelecom.eu/opensource/django-ldapdb/trunk@901 e071eeec-0327-468d-9b6a-08194a12b294

ldapdb/models/query.py

index fc211b45715099f3e48c2ca3eb489635249c921b..d0958b18c4386bb38c019327c293c7d84f8c29d4 100644 (file)
@@ -96,15 +96,15 @@ class Compiler(object):
         else:
             ordering = query.order_by or query.model._meta.ordering
         def cmpvals(x, y):
-            for field in ordering:
-                if field.startswith('-'):
-                    field = field[1:]
+            for fieldname in ordering:
+                if fieldname.startswith('-'):
+                    fieldname = fieldname[1:]
                     negate = True
                 else:
                     negate = False
-                attr = query.model._meta.get_field(field).db_column
-                attr_x = x[1].get(attr, '').lower()
-                attr_y = y[1].get(attr, '').lower()
+                field = query.model._meta.get_field(fieldname)
+                attr_x = field.from_ldap(x[1].get(field.db_column, []), connection=self.connection).lower()
+                attr_y = field.from_ldap(y[1].get(field.db_column, []), connection=self.connection).lower()
                 val = negate and cmp(attr_y, attr_x) or cmp(attr_x, attr_y)
                 if val:
                     return val