Skip to content

Commit d13f65b

Browse files
authored
Merge pull request #6 from cloudblue/bugfix/LITE-23661
LITE-23661 Added support for N or expressions (exp|exp...|exp)
2 parents fe156a0 + 5592cc2 commit d13f65b

File tree

3 files changed

+39
-25
lines changed

3 files changed

+39
-25
lines changed

poetry.lock

Lines changed: 22 additions & 22 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

py_rql/grammar.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@
4040
| _L_BRACE _or _R_BRACE
4141
4242
_or: _OR _logical_exp
43-
| _L_BRACE term "|" term _R_BRACE
44-
| _L_BRACE term ";" term _R_BRACE
43+
| _L_BRACE term ("|" term)+ _R_BRACE
44+
| _L_BRACE term (";" term)+ _R_BRACE
4545
4646
_logical_exp: _L_BRACE expr_term (_COMMA expr_term)+ _R_BRACE
4747

tests/test_parser/test_logical.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,23 @@ def test_and_ok(operator, expression):
5151
assert alias_result == base_result
5252

5353

54+
@pytest.mark.parametrize('operator', ['|', ';'])
55+
def test_or_ok_3(operator):
56+
query = '({logical})'.format(logical=operator.join(['a=b'] * 3))
57+
result = logical_transform(query)
58+
59+
assert result == {
60+
LogicalOperators.get_grammar_key(LogicalOperators.OR): [
61+
(ComparisonOperators.EQ, 'a', 'b'),
62+
(ComparisonOperators.EQ, 'a', 'b'),
63+
(ComparisonOperators.EQ, 'a', 'b'),
64+
],
65+
}
66+
67+
5468
@pytest.mark.parametrize('operator', ['|', ';'])
5569
@pytest.mark.parametrize('expression', ok_expressions)
56-
def test_or_ok(operator, expression):
70+
def test_or_ok_2(operator, expression):
5771
base_result = base_or_logical_transform(LogicalOperators.OR, expression)
5872
check_expression(LogicalOperators.OR, expression, base_result)
5973

0 commit comments

Comments
 (0)