Commit d91db01d authored by Nicolas Delaby's avatar Nicolas Delaby

Extend RawKey to handle None values

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@22143 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 0513d98e
......@@ -140,6 +140,8 @@ class SimpleQuery(QueryMixin):
search_key_class = DefaultKey
elif isinstance(value, float):
search_key_class = FloatKey
elif value is None:
return RawKey
return search_key_class
def _asSQLExpression(self, search_key_class, key, value, format=None, mode=None, range_value=None, stat__=None):
......
......@@ -39,5 +39,8 @@ class RawKey(SearchKey):
def buildSQLExpression(self, key, value,
format=None, mode=None, range_value=None, stat__=None):
where_expression = "%s = '%s'" %(key, value)
if value is not None:
where_expression = "%s = '%s'" % (key, value)
else:
where_expression = "%s is NULL" % (key)
return where_expression, []
......@@ -374,7 +374,12 @@ class TestSearchKeyQuery(unittest.TestCase):
'.',
"delivery.stock = '.'",
[])
#None values
self.compare(RawKey,
'title',
None,
"title is NULL",
[])
def test_06FullTextKey(self, quiet=quiet, run=run_all_test):
""" Check FullTextKey query generation"""
if not run: return
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment