Commit 77abb820 authored by Vincent Pelletier's avatar Vincent Pelletier

Handle the case of IN operator used with single value.


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