Commit 9276173f authored by Vincent Pelletier's avatar Vincent Pelletier

Add support for 'IN' SQL operator.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@15330 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent a7b83cd5
...@@ -336,7 +336,7 @@ class Query(QueryMixin): ...@@ -336,7 +336,7 @@ class Query(QueryMixin):
elif range_value == 'nlt' : elif range_value == 'nlt' :
where_expression.append("%s > %s" % (key, query_max)) where_expression.append("%s > %s" % (key, query_max))
elif isSimpleType(value) or isinstance(value, DateTime) \ elif isSimpleType(value) or isinstance(value, DateTime) \
or isinstance(value, (list, tuple)): or (isinstance(value, (list, tuple)) and self.operator.upper() != 'IN'):
# Convert into lists any value which contain a ; # Convert into lists any value which contain a ;
# Refer to _listGlobalActions DCWorkflow patch # Refer to _listGlobalActions DCWorkflow patch
# for example of use # for example of use
...@@ -398,6 +398,10 @@ class Query(QueryMixin): ...@@ -398,6 +398,10 @@ 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':
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))
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