@@ -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
@@ -2553,6 +2553,26 @@ def test_count_with_chainable_filter_multiple(service):
25532553 assert request .execute () == 3
25542554
25552555
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+
25562576@responses .activate
25572577def test_count_with_chainable_filter_or (service ):
25582578 """Check getting $count with $filter with FilterExpression syntax or"""
@@ -2561,7 +2581,7 @@ def test_count_with_chainable_filter_or(service):
25612581
25622582 responses .add (
25632583 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" ,
25652585 json = 3 ,
25662586 status = 200 )
25672587
@@ -2580,7 +2600,7 @@ def test_count_with_multiple_chainable_filters_startswith(service):
25802600
25812601 responses .add (
25822602 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" ,
25842604 json = 3 ,
25852605 status = 200 )
25862606
0 commit comments