Skip to content

Commit

Permalink
Merge pull request #19 from cloudblue/feature/LITE-30574-Deal-with-ex…
Browse files Browse the repository at this point in the history
…tra-brackets-in-the-query-RQL-lib

LITE-30574: Allowing braces exp braces as valid term_exp to catch up cases with extra parenthesis
  • Loading branch information
maxipavlovic authored Jul 15, 2024
2 parents 523ee35 + 03fa4a8 commit a874666
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
3 changes: 1 addition & 2 deletions py_rql/grammar.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
23 changes: 21 additions & 2 deletions tests/test_parser/test_logical.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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

0 comments on commit a874666

Please sign in to comment.