Commit 2ce7cccc authored by Vincent Pelletier's avatar Vincent Pelletier

Fix SearchText parsing: it was not passing desired logical_operator to...

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
parent 14a37433
...@@ -1935,9 +1935,9 @@ class Catalog(Folder, ...@@ -1935,9 +1935,9 @@ class Catalog(Folder,
subquery = self._buildQueryFromAbstractSyntaxTreeNode(subnode, search_key) subquery = self._buildQueryFromAbstractSyntaxTreeNode(subnode, search_key)
if subquery is not None: if subquery is not None:
append(subquery) append(subquery)
for comparison_operator, value_list in value_dict.iteritems():
append(search_key.buildQuery(value_list, comparison_operator=comparison_operator))
operator = node.getLogicalOperator() 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: if operator == 'not' or len(query_list) > 1:
result = ComplexQuery(query_list, operator=operator) result = ComplexQuery(query_list, operator=operator)
elif len(query_list) == 1: elif len(query_list) == 1:
......
...@@ -299,6 +299,10 @@ class TestSQLCatalog(unittest.TestCase): ...@@ -299,6 +299,10 @@ class TestSQLCatalog(unittest.TestCase):
{column: '%a'}) {column: '%a'})
self.catalog(ReferenceQuery(ReferenceQuery(operator='<', keyword='a'), operator='and'), self.catalog(ReferenceQuery(ReferenceQuery(operator='<', keyword='a'), operator='and'),
{column: '<a'}) {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'), self.catalog(ReferenceQuery(ReferenceQuery(operator='<', keyword='path'), operator='and'),
{column: {'query': 'path', 'range': 'max'}}) {column: {'query': 'path', 'range': 'max'}})
self.catalog(ReferenceQuery(ReferenceQuery( self.catalog(ReferenceQuery(ReferenceQuery(
......
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