if isinstance(item, WhereNode):
bits.append(item.as_sql())
continue
- constraint, x, y, values = item
+ constraint, lookup_type, y, values = item
+ comp = get_lookup_operator(lookup_type)
if hasattr(constraint, "col"):
# django 1.2
- comp = get_lookup_operator(constraint.lookup_type)
clause = "(%s%s%s)" % (constraint.col, comp, values)
else:
# django 1.1
(table, column, db_type) = constraint
- comp = get_lookup_operator(x)
equal_bits = [ "(%s%s%s)" % (column, comp, value) for value in values ]
if len(equal_bits) == 1:
clause = equal_bits[0]
self.assertEquals(escape_ldap_filter('foo\\bar'), 'foo\\5cbar')
self.assertEquals(escape_ldap_filter('foo\\bar*wiz'), 'foo\\5cbar\\2awiz')
- def test_char_field(self):
+ def test_char_field_exact(self):
where = WhereNode()
where.add((Constraint("cn", "cn", CharField()), 'exact', "test"), AND)
self.assertEquals(where.as_sql(), "(cn=test)")
where.add((Constraint("cn", "cn", CharField()), 'exact', "(test)"), AND)
self.assertEquals(where.as_sql(), "(cn=\\28test\\29)")
+ def test_char_field_in(self):
where = WhereNode()
where.add((Constraint("cn", "cn", CharField()), 'in', ["foo", "bar"]), AND)
self.assertEquals(where.as_sql(), "(|(cn=foo)(cn=bar))")
where.add((Constraint("cn", "cn", CharField()), 'in', ["(foo)", "(bar)"]), AND)
self.assertEquals(where.as_sql(), "(|(cn=\\28foo\\29)(cn=\\28bar\\29))")
+ def test_char_field_startswith(self):
where = WhereNode()
where.add((Constraint("cn", "cn", CharField()), 'startswith', "test"), AND)
self.assertEquals(where.as_sql(), "(cn=test*)")
where.add((Constraint("cn", "cn", CharField()), 'endswith', "test"), AND)
self.assertEquals(where.as_sql(), "(cn=*test)")
- where = WhereNode()
- where.add((Constraint("cn", "cn", CharField()), 'in', ["foo", "bar"]), AND)
- self.assertEquals(where.as_sql(), "(|(cn=foo)(cn=bar))")
-
+ def test_char_field_contains(self):
where = WhereNode()
where.add((Constraint("cn", "cn", CharField()), 'contains', "test"), AND)
self.assertEquals(where.as_sql(), "(cn=*test*)")