class ImageField(fields.Field):
def get_db_prep_lookup(self, lookup_type, value):
+ "Returns field's value prepared for database lookup."
+ return [self.get_prep_lookup(lookup_type, value)]
+
+ def get_prep_lookup(self, lookup_type, value):
+ "Perform preliminary non-db specific lookup checks and conversions"
raise TypeError("ImageField has invalid lookup: %s" % lookup_type)
class IntegerField(fields.IntegerField):
def get_db_prep_lookup(self, lookup_type, value):
- if lookup_type in ('exact', 'gte', 'lte'):
- return [value]
+ "Returns field's value prepared for database lookup."
+ return [self.get_prep_lookup(lookup_type, value)]
+ def get_prep_lookup(self, lookup_type, value):
+ "Perform preliminary non-db specific lookup checks and conversions"
+ if lookup_type in ('exact', 'gte', 'lte'):
+ return value
raise TypeError("IntegerField has invalid lookup: %s" % lookup_type)
class ListField(fields.Field):
__metaclass__ = SubfieldBase
def get_db_prep_lookup(self, lookup_type, value):
+ "Returns field's value prepared for database lookup."
+ return [self.get_prep_lookup(lookup_type, value)]
+
+ def get_prep_lookup(self, lookup_type, value):
+ "Perform preliminary non-db specific lookup checks and conversions"
+ if lookup_type == 'contains':
+ return escape_ldap_filter(value)
raise TypeError("ListField has invalid lookup: %s" % lookup_type)
def to_python(self, value):
where.add((Constraint("uid", "uid", IntegerField()), 'lte', 1), AND)
self.assertEquals(where.as_sql(), "(uid<=1)")
+ def test_list_field_contains(self):
+ where = WhereNode()
+ where.add((Constraint("memberUid", "memberUid", ListField()), 'contains', 'foouser'), AND)
+ self.assertEquals(where.as_sql(), "(memberUid=foouser)")
+
def test_and(self):
where = WhereNode()
where.add((Constraint("cn", "cn", CharField()), 'exact', "foo"), AND)