Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LITE-30574: Allowing braces exp braces as valid term_exp to catch up cases with extra parenthesis #19

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading