X-Git-Url: https://git.stderr.nl/gitweb?p=matthijs%2Fupstream%2Fdjango-ldapdb.git;a=blobdiff_plain;f=ldapdb%2Fmodels%2Fquery.py;h=91a3f62e2058bf8587342559c04ffefee3c58487;hp=1fddeeeb1aea3b8bb0ece0f4a7b079fa8d802b84;hb=5c3683a37e2afc87654d4b44c3f8e9fbe7872076;hpb=62de279ee18d0054b8eef779844365723250b96b diff --git a/ldapdb/models/query.py b/ldapdb/models/query.py index 1fddeee..91a3f62 100644 --- a/ldapdb/models/query.py +++ b/ldapdb/models/query.py @@ -56,8 +56,13 @@ class Constraint(BaseConstraint): """ An object that can be passed to WhereNode.add() and knows how to pre-process itself prior to including in the WhereNode. + + NOTES: + - we redefine this class, because when self.field is None calls + Field().get_db_prep_lookup(), which short-circuits our LDAP-specific code. + - the connection argument defaults to None for django 1.1 compatibility """ - def process(self, lookup_type, value): + def process(self, lookup_type, value, connection=None): """ Returns a tuple of data suitable for inclusion in a WhereNode instance. @@ -67,10 +72,12 @@ class Constraint(BaseConstraint): try: if self.field: - params = self.field.get_db_prep_lookup(lookup_type, value) + params = self.field.get_db_prep_lookup(lookup_type, value, + connection=connection, prepared=True) db_type = self.field.db_type() else: - params = CharField().get_db_prep_lookup(lookup_type, value) + params = CharField().get_db_prep_lookup(lookup_type, value, + connection=connection, prepared=True) db_type = None except ObjectDoesNotExist: raise EmptyShortCircuit