storage: make ILike work with None attributes
This commit is contained in:
parent
df8cce74f0
commit
946904f753
|
@ -302,10 +302,13 @@ def test_select_criteria_ilike():
|
|||
test.foo = 'bar'
|
||||
test.store()
|
||||
|
||||
test.foo = None # makes sure it doesn't break on None
|
||||
test.store()
|
||||
|
||||
assert len(Foobar.select()) == 50
|
||||
|
||||
assert [x.id for x in Foobar.select([st.ILike('foo', 'bar')], order_by='id')] == range(21, 51)
|
||||
assert [x.id for x in Foobar.select([st.ILike('foo', 'BAR')], order_by='id')] == range(21, 51)
|
||||
assert [x.id for x in Foobar.select([st.ILike('foo', 'bar')], order_by='id')] == range(21, 50)
|
||||
assert [x.id for x in Foobar.select([st.ILike('foo', 'BAR')], order_by='id')] == range(21, 50)
|
||||
|
||||
def test_store_async():
|
||||
Foobar.wipe()
|
||||
|
|
|
@ -150,7 +150,7 @@ class And(Criteria):
|
|||
|
||||
class ILike(Criteria):
|
||||
def build_lambda(self):
|
||||
return lambda x: self.value.lower() in getattr(x, self.attribute, '').lower()
|
||||
return lambda x: self.value.lower() in (getattr(x, self.attribute) or '').lower()
|
||||
|
||||
def parse_clause(clause):
|
||||
# creates a callable out of a clause
|
||||
|
|
Loading…
Reference in New Issue