X-Git-Url: https://git.stderr.nl/gitweb?p=matthijs%2Fupstream%2Fdjango-ldapdb.git;a=blobdiff_plain;f=ldapdb%2Fmodels%2Fquery.py;h=f433956d52071c5bdac9f71a842dcf565449193f;hp=d0958b18c4386bb38c019327c293c7d84f8c29d4;hb=6cba2f11be4c464583e2e303d33a013918358e5a;hpb=a6255cb185ff6ce55d8760ef9b3aefbb9ddc4194 diff --git a/ldapdb/models/query.py b/ldapdb/models/query.py index d0958b1..f433956 100644 --- a/ldapdb/models/query.py +++ b/ldapdb/models/query.py @@ -103,8 +103,13 @@ class Compiler(object): else: negate = False 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() + attr_x = field.from_ldap(x[1].get(field.db_column, []), connection=self.connection) + attr_y = field.from_ldap(y[1].get(field.db_column, []), connection=self.connection) + # perform case insensitive comparison + if hasattr(attr_x, 'lower'): + attr_x = attr_x.lower() + if hasattr(attr_y, 'lower'): + attr_y = attr_y.lower() val = negate and cmp(attr_y, attr_x) or cmp(attr_x, attr_y) if val: return val @@ -182,7 +187,7 @@ class Query(BaseQuery): super(Query, self).__init__(*args, **kwargs) self.connection = ldapdb.connection - def get_count(self): + def get_count(self, using=None): filterstr = ''.join(['(objectClass=%s)' % cls for cls in self.model.object_classes]) sql, params = self.where.as_sql() filterstr += sql