super(CharField, self).__init__(*args, **kwargs)
def get_db_prep_lookup(self, lookup_type, value):
+ "Returns field's value prepared for database lookup."
if lookup_type == 'endswith':
return ["*%s" % escape_ldap_filter(value)]
elif lookup_type == 'startswith':
raise TypeError("CharField has invalid lookup: %s" % lookup_type)
def get_prep_lookup(self, lookup_type, value):
- return escape_ldap_filter(value)
-
+ "Perform preliminary non-db specific lookup checks and conversions"
+ if lookup_type == 'endswith':
+ return "*%s" % escape_ldap_filter(value)
+ elif lookup_type == 'startswith':
+ return "%s*" % escape_ldap_filter(value)
+ elif lookup_type == 'contains':
+ return "*%s*" % escape_ldap_filter(value)
+ elif lookup_type == 'exact':
+ return escape_ldap_filter(value)
+ elif lookup_type == 'in':
+ return [escape_ldap_filter(v) for v in value]
+
+ raise TypeError("CharField has invalid lookup: %s" % lookup_type)
+
class ImageField(fields.Field):
def get_db_prep_lookup(self, lookup_type, value):
raise TypeError("ImageField has invalid lookup: %s" % lookup_type)
if isinstance(item, WhereNode):
bits.append(item.as_sql())
continue
+
constraint, lookup_type, y, values = item
comp = get_lookup_operator(lookup_type)
if hasattr(constraint, "col"):
# django 1.2
- clause = "(%s%s%s)" % (constraint.col, comp, values)
+ column = constraint.col
+ if lookup_type == 'in':
+ equal_bits = [ "(%s%s%s)" % (column, comp, value) for value in values ]
+ clause = '(|%s)' % ''.join(equal_bits)
+ else:
+ clause = "(%s%s%s)" % (constraint.col, comp, values)
else:
# django 1.1
(table, column, db_type) = constraint
clause = equal_bits[0]
else:
clause = '(|%s)' % ''.join(equal_bits)
+
if self.negated:
bits.append('(!%s)' % clause)
else: