Skip to content

Commit b0a6235

Browse files
committed
Fixes bug when chaining expressions with OR
1 parent 71b8043 commit b0a6235

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

pyodata/v2/service.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1276,7 +1276,7 @@ def _combine_expressions(self, expressions):
12761276
return combined
12771277

12781278
return expressions[0]
1279-
1279+
12801280
# pylint: disable=too-many-return-statements, too-many-branches
12811281
def _build_expression(self, field_name, operator, value):
12821282
target_field = self.proprty_obj(field_name)

tests/test_service_v2.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2541,7 +2541,7 @@ def test_count_with_chainable_filter_multiple(service):
25412541

25422542
responses.add(
25432543
responses.GET,
2544-
f"{service.url}/Employees/$count?%24filter=ID%20eq%2023%20and%20NickName%20eq%20%27Steve%27",
2544+
f"{service.url}/Employees/$count?%24filter=%28ID%20eq%2023%29%20and%20%28NickName%20eq%20%27Steve%27%29",
25452545
json=3,
25462546
status=200)
25472547

@@ -2557,7 +2557,7 @@ def test_count_with_chainable_filter_multiple(service):
25572557
def test_chaining_fix(service):
25582558
from pyodata.v2.service import FilterExpression as Q
25592559

2560-
url = f"{service.url}/Employees?%24filter=startswith%28NameFirst%2C+%27Steve%27%29+eq+true+and+ID+eq+23+or+ID+eq+25+or+ID+eq+28"
2560+
url = f"{service.url}/Employees?%24filter=%28startswith%28NameFirst%2C+%27Steve%27%29+eq+true%29+and+%28ID+eq+23+or+ID+eq+25+or+ID+eq+28%29"
25612561

25622562
responses.add(
25632563
responses.GET,
@@ -2581,7 +2581,7 @@ def test_count_with_chainable_filter_or(service):
25812581

25822582
responses.add(
25832583
responses.GET,
2584-
f"{service.url}/Employees/$count?$filter=%28ID%20eq%2023%20and%20NickName%20eq%20%27Steve%27%29%20or%20%28ID%20eq%2025%20and%20NickName%20eq%20%27Tim%27%29",
2584+
f"{service.url}/Employees/$count?$filter=%28%28ID%20eq%2023%29%20and%20%28NickName%20eq%20%27Steve%27%29%29%20or%20%28%28ID%20eq%2025%29%20and%20%28NickName%20eq%20%27Tim%27%29%29",
25852585
json=3,
25862586
status=200)
25872587

@@ -2600,7 +2600,7 @@ def test_count_with_multiple_chainable_filters_startswith(service):
26002600

26012601
responses.add(
26022602
responses.GET,
2603-
f"{service.url}/Employees/$count?$filter=%28ID%20eq%2023%20and%20startswith%28NickName%2C%20%27Ste%27%29%20eq%20true%29%20or%20%28ID%20eq%2025%20and%20NickName%20eq%20%27Tim%27%29",
2603+
f"{service.url}/Employees/$count?$filter=%28%28ID%20eq%2023%29%20and%20%28startswith%28NickName%2C%20%27Ste%27%29%20eq%20true%29%29%20or%20%28%28ID%20eq%2025%29%20and%20%28NickName%20eq%20%27Tim%27%29%29",
26042604
json=3,
26052605
status=200)
26062606

0 commit comments

Comments
 (0)