Skip to content

Commit

Permalink
Merge pull request #6 from cloudblue/bugfix/LITE-23661
Browse files Browse the repository at this point in the history
LITE-23661 Added support for N or expressions (exp|exp...|exp)
  • Loading branch information
zzzevaka authored May 17, 2022
2 parents fe156a0 + 5592cc2 commit d13f65b
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 25 deletions.
44 changes: 22 additions & 22 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions py_rql/grammar.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@
| _L_BRACE _or _R_BRACE
_or: _OR _logical_exp
| _L_BRACE term "|" term _R_BRACE
| _L_BRACE term ";" term _R_BRACE
| _L_BRACE term ("|" term)+ _R_BRACE
| _L_BRACE term (";" term)+ _R_BRACE
_logical_exp: _L_BRACE expr_term (_COMMA expr_term)+ _R_BRACE
Expand Down
16 changes: 15 additions & 1 deletion tests/test_parser/test_logical.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,23 @@ def test_and_ok(operator, expression):
assert alias_result == base_result


@pytest.mark.parametrize('operator', ['|', ';'])
def test_or_ok_3(operator):
query = '({logical})'.format(logical=operator.join(['a=b'] * 3))
result = logical_transform(query)

assert result == {
LogicalOperators.get_grammar_key(LogicalOperators.OR): [
(ComparisonOperators.EQ, 'a', 'b'),
(ComparisonOperators.EQ, 'a', 'b'),
(ComparisonOperators.EQ, 'a', 'b'),
],
}


@pytest.mark.parametrize('operator', ['|', ';'])
@pytest.mark.parametrize('expression', ok_expressions)
def test_or_ok(operator, expression):
def test_or_ok_2(operator, expression):
base_result = base_or_logical_transform(LogicalOperators.OR, expression)
check_expression(LogicalOperators.OR, expression, base_result)

Expand Down

0 comments on commit d13f65b

Please sign in to comment.