From 6cd6254ef6f989d54fd1b50ff7b67a442d00e8cc Mon Sep 17 00:00:00 2001
From: Romain Courteaud <romain@nexedi.com>
Date: Thu, 24 Nov 2005 12:59:23 +0000
Subject: [PATCH] Added parentheses to SQL expression, only for easier
 visualisation.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@4400 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 product/CMFCategory/CategoryTool.py | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/product/CMFCategory/CategoryTool.py b/product/CMFCategory/CategoryTool.py
index 0961f5d064..0b2f22aec4 100755
--- a/product/CMFCategory/CategoryTool.py
+++ b/product/CMFCategory/CategoryTool.py
@@ -1232,7 +1232,7 @@ class CategoryTool( UniqueObject, Folder, Base ):
 
     # SQL Expression Building
     security.declareProtected(Permissions.AccessContentsInformation, 'buildSQLSelector')
-    def buildSQLSelector(self, category_list,query_table='category'):
+    def buildSQLSelector(self, category_list, query_table='category'):
       """
         Returns an SQL selector expression from a list of categories
         We make here a simple method wich simply checks membership
@@ -1260,7 +1260,7 @@ class CategoryTool( UniqueObject, Folder, Base ):
               expression += ' AND %s.base_category_uid is NULL' % query_table
             else:
               expression += ' AND %s.base_category_uid = %s' % (query_table,base_category_uid)
-            sql_expr += [expression]
+            sql_expr += ["(%s)" % expression]
         else:
           single_sql_expr = []
           for single_category in category:
@@ -1275,11 +1275,11 @@ class CategoryTool( UniqueObject, Folder, Base ):
                 expression += ' AND %s.base_category_uid is NULL' % query_table
               else:
                 expression += ' AND %s.base_category_uid = %s' % (query_table,base_category_uid)
-              single_sql_expr += [expression]
+              single_sql_expr += ["(%s)" % expression]
           if len(single_sql_expr) > 0:
-            sql_expr += "( %s )" % string.join(single_sql_expr, ' OR ')
+            sql_expr += "( %s )" % ' OR '.join(single_sql_expr)
       if len(sql_expr) > 0:
-        sql_expr = string.join(sql_expr, ' OR ')
+        sql_expr = ' OR '.join(sql_expr)
       return sql_expr
 
     security.declareProtected( Permissions.AccessContentsInformation, 'getCategoryMemberValueList' )
-- 
2.30.9