diff --git a/ckanext/querytool/helpers.py b/ckanext/querytool/helpers.py index 1eb32bee..2876f896 100644 --- a/ckanext/querytool/helpers.py +++ b/ckanext/querytool/helpers.py @@ -294,7 +294,11 @@ def _create_where_clause(filters): for idx, _ in enumerate(filters): op = u'=' name = _['name'] - value = _['value'].replace('\'', '\'\'') + + if isinstance(_['value'], str): + value = _['value'].replace('\'', '\'\'') + else: + value = _['value'] if idx == 0: where_clause = u'WHERE ("{0}" {1} \'{2}\')'.format( @@ -307,7 +311,12 @@ def _create_where_clause(filters): _ = filters[0] op = u'=' name = _['name'] - value = _['value'] + + if isinstance(_['value'], str): + value = _['value'].replace('\'', '\'\'') + else: + value = _['value'] + where_clause = \ u'WHERE ("{0}" {1} \'{2}\')'.format( name,