diff --git a/product/ZSQLCatalog/Query/SimpleQuery.py b/product/ZSQLCatalog/Query/SimpleQuery.py index d50326659025e794101f65255d5244cb45479282..20f498ea07417c385c00d349c9714862ffacb12a 100644 --- a/product/ZSQLCatalog/Query/SimpleQuery.py +++ b/product/ZSQLCatalog/Query/SimpleQuery.py @@ -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): diff --git a/product/ZSQLCatalog/SearchKey/RawKey.py b/product/ZSQLCatalog/SearchKey/RawKey.py index dd464c68807d7cfacad9d91fba4c05649539d59d..064bf7c4b45aa1fc328ac4669eb178a1f4532891 100644 --- a/product/ZSQLCatalog/SearchKey/RawKey.py +++ b/product/ZSQLCatalog/SearchKey/RawKey.py @@ -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, [] diff --git a/product/ZSQLCatalog/tests/testSearchKeys.py b/product/ZSQLCatalog/tests/testSearchKeys.py index df504f4aa783503fcdbfbacea5bbc270c0e98250..e75ff300ad4733c596f1278135216807833cc5e5 100644 --- a/product/ZSQLCatalog/tests/testSearchKeys.py +++ b/product/ZSQLCatalog/tests/testSearchKeys.py @@ -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