From 2ce7cccca4427283f148ecebb6badf790b3f6760 Mon Sep 17 00:00:00 2001 From: Vincent Pelletier <vincent@nexedi.com> Date: Tue, 10 Mar 2009 14:49:03 +0000 Subject: [PATCH] Fix SearchText parsing: it was not passing desired logical_operator to buildQuery, causing AND to becore OR (only for logical operator syntax tree node directly containing leaf nodes). git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@25945 20353a03-c40f-0410-a6d1-a30d3c3de9de --- product/ZSQLCatalog/SQLCatalog.py | 4 ++-- product/ZSQLCatalog/tests/testSQLCatalog.py | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/product/ZSQLCatalog/SQLCatalog.py b/product/ZSQLCatalog/SQLCatalog.py index 1794c16d6a..8202ec9b81 100644 --- a/product/ZSQLCatalog/SQLCatalog.py +++ b/product/ZSQLCatalog/SQLCatalog.py @@ -1935,9 +1935,9 @@ class Catalog(Folder, subquery = self._buildQueryFromAbstractSyntaxTreeNode(subnode, search_key) if subquery is not None: append(subquery) - for comparison_operator, value_list in value_dict.iteritems(): - append(search_key.buildQuery(value_list, comparison_operator=comparison_operator)) operator = node.getLogicalOperator() + for comparison_operator, value_list in value_dict.iteritems(): + append(search_key.buildQuery(value_list, comparison_operator=comparison_operator, logical_operator=operator)) if operator == 'not' or len(query_list) > 1: result = ComplexQuery(query_list, operator=operator) elif len(query_list) == 1: diff --git a/product/ZSQLCatalog/tests/testSQLCatalog.py b/product/ZSQLCatalog/tests/testSQLCatalog.py index 3ae3b50199..d383680bf0 100644 --- a/product/ZSQLCatalog/tests/testSQLCatalog.py +++ b/product/ZSQLCatalog/tests/testSQLCatalog.py @@ -299,6 +299,10 @@ class TestSQLCatalog(unittest.TestCase): {column: '%a'}) self.catalog(ReferenceQuery(ReferenceQuery(operator='<', keyword='a'), operator='and'), {column: '<a'}) + self.catalog(ReferenceQuery(ReferenceQuery(ReferenceQuery(operator='like', keyword='%a%'), ReferenceQuery(operator='like', keyword='%b%'), operator='and'), operator='and'), + {column: 'a AND b'}) + self.catalog(ReferenceQuery(ReferenceQuery(ReferenceQuery(operator='like', keyword='%a%'), ReferenceQuery(operator='like', keyword='%b%'), operator='or'), operator='and'), + {column: 'a OR b'}) self.catalog(ReferenceQuery(ReferenceQuery(operator='<', keyword='path'), operator='and'), {column: {'query': 'path', 'range': 'max'}}) self.catalog(ReferenceQuery(ReferenceQuery( -- 2.30.9