@@ -2541,7 +2541,7 @@ def test_count_with_chainable_filter_multiple(service):
2541
2541
2542
2542
responses .add (
2543
2543
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 " ,
2545
2545
json = 3 ,
2546
2546
status = 200 )
2547
2547
@@ -2553,6 +2553,26 @@ def test_count_with_chainable_filter_multiple(service):
2553
2553
assert request .execute () == 3
2554
2554
2555
2555
2556
+ @responses .activate
2557
+ def test_chaining_fix (service ):
2558
+ from pyodata .v2 .service import FilterExpression as Q
2559
+
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"
2561
+
2562
+ responses .add (
2563
+ responses .GET ,
2564
+ url ,
2565
+ json = 3 ,
2566
+ status = 200 )
2567
+
2568
+ employees = service .entity_sets .Employees .get_entities ()
2569
+ request = employees .filter (Q (NameFirst__startswith = "Steve" ), Q (ID__in = [23 , 25 , 28 ]))
2570
+
2571
+ assert isinstance (request , pyodata .v2 .service .GetEntitySetRequest )
2572
+
2573
+ assert request .execute () == 3
2574
+
2575
+
2556
2576
@responses .activate
2557
2577
def test_count_with_chainable_filter_or (service ):
2558
2578
"""Check getting $count with $filter with FilterExpression syntax or"""
@@ -2561,7 +2581,7 @@ def test_count_with_chainable_filter_or(service):
2561
2581
2562
2582
responses .add (
2563
2583
responses .GET ,
2564
- 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" ,
2565
2585
json = 3 ,
2566
2586
status = 200 )
2567
2587
@@ -2580,7 +2600,7 @@ def test_count_with_multiple_chainable_filters_startswith(service):
2580
2600
2581
2601
responses .add (
2582
2602
responses .GET ,
2583
- 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" ,
2584
2604
json = 3 ,
2585
2605
status = 200 )
2586
2606
0 commit comments