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..f9f87ec 100644 --- a/tests/test_parser/test_logical.py +++ b/tests/test_parser/test_logical.py @@ -201,8 +201,11 @@ 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(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 +247,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