From 03fa4a8f69513da34ca996d9d973fcf39de79de1 Mon Sep 17 00:00:00 2001 From: Agostina Date: Fri, 12 Jul 2024 15:20:01 +0200 Subject: [PATCH] LITE-30574: Allowing braces exp braces as valid term_exp to catch up cases with extra parentesis --- py_rql/grammar.py | 3 +-- tests/test_parser/test_logical.py | 23 +++++++++++++++++++++-- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/py_rql/grammar.py b/py_rql/grammar.py index a7757dc..9de5099 100644 --- a/py_rql/grammar.py +++ b/py_rql/grammar.py @@ -20,8 +20,7 @@ term: expr_term | logical | tuple - | _L_BRACE logical _R_BRACE - | _L_BRACE tuple _R_BRACE + | _L_BRACE term _R_BRACE expr_term: comp | listing diff --git a/tests/test_parser/test_logical.py b/tests/test_parser/test_logical.py index 950f62d..3b56021 100644 --- a/tests/test_parser/test_logical.py +++ b/tests/test_parser/test_logical.py @@ -201,8 +201,18 @@ def test_or_chain(query): } -def test_logical_tuple_and_not(): - result = logical_transform('(not(id=fg))') +@pytest.mark.parametrize( + 'query', + ( + '(not(id=fg))', + '((not(id=fg)))', + 'not(eq(id,fg))', + '((((not(id=fg)))))', + 'not((eq(id,fg)))', + ), +) +def test_logical_tuple_and_not(query): + result = logical_transform(query) not_grammar_key = LogicalOperators.get_grammar_key(LogicalOperators.NOT) @@ -244,3 +254,12 @@ def test_logical_tuple_nesting_ands_and_ors(): (ComparisonOperators.EQ, 'id', '*dziad*'), ], } + + +@pytest.mark.parametrize('query', ('((not(ilike(id,*8684*))))', )) +def test_logical_tuple_not_and_ilike(query): + result = logical_transform(query) + + not_grammar_key = LogicalOperators.get_grammar_key(LogicalOperators.NOT) + + assert not_grammar_key in result