Commit e7584a95 authored by Vincent Pelletier's avatar Vincent Pelletier

Handle the case where the list given to IN operator is empty.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@15333 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 9271fbc4
...@@ -399,9 +399,12 @@ class Query(QueryMixin): ...@@ -399,9 +399,12 @@ class Query(QueryMixin):
elif value is None: elif value is None:
where_expression.append("%s is NULL" % (key)) where_expression.append("%s is NULL" % (key))
elif isinstance(value, (tuple, list)) and self.operator.upper() == 'IN': elif isinstance(value, (tuple, list)) and self.operator.upper() == 'IN':
if len(value):
escaped_value_list = [self._quoteSQLString(x) for x in value] escaped_value_list = [self._quoteSQLString(x) for x in value]
escaped_value_string = ', '.join(escaped_value_list) escaped_value_string = ', '.join(escaped_value_list)
where_expression.append("%s IN (%s)" % (key, escaped_value_string)) where_expression.append("%s IN (%s)" % (key, escaped_value_string))
else:
where_expression.('0') # "foo IN ()" is invalid SQL syntax, so use a "false" value.
else: else:
where_expression.append("%s = %s" % where_expression.append("%s = %s" %
(self._quoteSQLKey(key), self._quoteSQLString(value))) (self._quoteSQLKey(key), self._quoteSQLString(value)))
......
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