From: jlaine Date: Mon, 31 May 2010 18:07:06 +0000 (+0000) Subject: fix ordering X-Git-Url: https://git.stderr.nl/gitweb?a=commitdiff_plain;h=a6255cb185ff6ce55d8760ef9b3aefbb9ddc4194;p=matthijs%2Fupstream%2Fdjango-ldapdb.git fix ordering git-svn-id: https://svn.bolloretelecom.eu/opensource/django-ldapdb/trunk@901 e071eeec-0327-468d-9b6a-08194a12b294 --- diff --git a/ldapdb/models/query.py b/ldapdb/models/query.py index fc211b4..d0958b1 100644 --- a/ldapdb/models/query.py +++ b/ldapdb/models/query.py @@ -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