[Erp5-report] r15330 - /erp5/trunk/products/ZSQLCatalog/SQLCatalog.py

nobody at svn.erp5.org nobody at svn.erp5.org
Thu Jul 26 18:34:41 CEST 2007


Author: vincent
Date: Thu Jul 26 18:34:41 2007
New Revision: 15330

URL: http://svn.erp5.org?rev=15330&view=rev
Log:
Add support for 'IN' SQL operator.

Modified:
    erp5/trunk/products/ZSQLCatalog/SQLCatalog.py

Modified: erp5/trunk/products/ZSQLCatalog/SQLCatalog.py
URL: http://svn.erp5.org/erp5/trunk/products/ZSQLCatalog/SQLCatalog.py?rev=15330&r1=15329&r2=15330&view=diff
==============================================================================
--- erp5/trunk/products/ZSQLCatalog/SQLCatalog.py (original)
+++ erp5/trunk/products/ZSQLCatalog/SQLCatalog.py Thu Jul 26 18:34:41 2007
@@ -336,7 +336,7 @@
       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 @@
 
     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)))




More information about the Erp5-report mailing list