Commit fa6e003b authored by Jérome Perrin's avatar Jérome Perrin Committed by Kazuhiko Shiozaki

ZSQLCatalog: reject unhandled search value types.

Raise an exception instead of casting to string unhandled search values,
because it's more likely that caller accidentally passed a wrong value.
parent 8570e0f0
......@@ -1240,6 +1240,14 @@ class TestERP5Catalog(ERP5TypeTestCase, LogInterceptor):
[x.getObject() for x in self.getCatalogTool()(
parent_title=person_module.getTitle())])
def test_unhandled_search_value(self):
class UnhandledClass:
pass
with self.assertRaisesRegex(
TypeError,
'Unhandled value class: UnhandledClass.*'):
self.getCatalogTool()(title=UnhandledClass())
def test_45_QueryAndComplexQuery(self):
"""
"""
......
......@@ -29,7 +29,6 @@
##############################################################################
import six
from six import string_types as basestring
from zLOG import LOG
from DateTime import DateTime
from Products.ZSQLCatalog.interfaces.operator import IOperator
from Products.ZSQLCatalog.Utils import sqlquote as escapeString
......@@ -45,8 +44,7 @@ def valueDateTimeRenderer(value):
return '"%s"' % (value.toZone('UTC').ISO(), )
def valueDefaultRenderer(value):
LOG('OperatorBase', 0, 'Unhandled value class: %s (%r). Converted to string and escaped.' % (value.__class__.__name__, value))
return escapeString(str(value))
raise TypeError('Unhandled value class: %s (%r)' % (value.__class__.__name__, value))
def valueNoneRenderer(value):
return 'NULL'
......
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