From 9276173f1c786161722ef58c906d6ca7a3be007a Mon Sep 17 00:00:00 2001 From: Vincent Pelletier <vincent@nexedi.com> Date: Thu, 26 Jul 2007 16:34:41 +0000 Subject: [PATCH] Add support for 'IN' SQL operator. git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@15330 20353a03-c40f-0410-a6d1-a30d3c3de9de --- product/ZSQLCatalog/SQLCatalog.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/product/ZSQLCatalog/SQLCatalog.py b/product/ZSQLCatalog/SQLCatalog.py index 42bb4b4e73..eaf63d6ffa 100644 --- a/product/ZSQLCatalog/SQLCatalog.py +++ b/product/ZSQLCatalog/SQLCatalog.py @@ -336,7 +336,7 @@ class Query(QueryMixin): elif range_value == 'nlt' : where_expression.append("%s > %s" % (key, query_max)) 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 ; # Refer to _listGlobalActions DCWorkflow patch # for example of use @@ -398,6 +398,10 @@ class Query(QueryMixin): elif value is None: 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: where_expression.append("%s = %s" % (self._quoteSQLKey(key), self._quoteSQLString(value))) -- 2.30.9