@@ -1034,3 +1034,78 @@ def test_execute_should_get_all_form_fields_included_hidden(self):
10341034 response .body ,
10351035 '{"success": "hidden_value"}' ,
10361036 )
1037+
1038+ def test_execute_should_ignore_all_records_subset_query_filters_when_all_records_is_false (self ):
1039+ """Test that when all_records is false, filters from all_records_subset_query are ignored."""
1040+ collected_filter = None
1041+
1042+ async def execute_with_filter_capture (ctx , rb ):
1043+ nonlocal collected_filter
1044+ collected_filter = ctx .filter
1045+ return rb .success ("done" )
1046+
1047+ self .decorated_collection_book .add_action (
1048+ "test_bulk_action" ,
1049+ {
1050+ "scope" : ActionsScope .BULK ,
1051+ "execute" : execute_with_filter_capture ,
1052+ },
1053+ )
1054+
1055+ body_params = {
1056+ "data" : {
1057+ "attributes" : {
1058+ "values" : {},
1059+ "ids" : ["1" , "2" ],
1060+ "collection_name" : "Book" ,
1061+ "parent_collection_name" : None ,
1062+ "parent_collection_id" : None ,
1063+ "parent_association_name" : None ,
1064+ "all_records" : False ,
1065+ "all_records_subset_query" : {
1066+ "fields[Book]" : "id,name,cost" ,
1067+ "page[number]" : 1 ,
1068+ "page[size]" : 15 ,
1069+ "sort" : "-id" ,
1070+ "timezone" : "Europe/Paris" ,
1071+ # This filter should be IGNORED when all_records is false
1072+ "filters" : '{"field":"id","operator":"greater_than","value":"100"}' ,
1073+ },
1074+ "all_records_ids_excluded" : [],
1075+ "smart_action_id" : "Book-test_bulk_action" ,
1076+ "signed_approval_request" : None ,
1077+ },
1078+ "type" : "custom-action-requests" ,
1079+ }
1080+ }
1081+
1082+ request = ActionRequest (
1083+ method = RequestMethod .POST ,
1084+ action_name = "test_bulk_action" ,
1085+ collection = self .decorated_collection_book ,
1086+ body = body_params ,
1087+ query = {
1088+ "timezone" : "Europe/Paris" ,
1089+ "collection_name" : "Book" ,
1090+ "action_name" : 0 ,
1091+ "slug" : "test_bulk_action" ,
1092+ },
1093+ headers = {},
1094+ user = self .mocked_caller ,
1095+ client_ip = "127.0.0.1" ,
1096+ )
1097+
1098+ response = self .loop .run_until_complete (self .action_resource .execute (request ))
1099+ self .assertEqual (response .status , 200 )
1100+
1101+ # The filter should NOT contain the "greater_than" condition from all_records_subset_query
1102+ # It should only contain the ID match condition for ids [1, 2]
1103+ self .assertIsNotNone (collected_filter )
1104+ if collected_filter .condition_tree :
1105+ filter_str = str (collected_filter .condition_tree )
1106+ # Should not contain the greater_than filter from all_records_subset_query
1107+ self .assertNotIn ("greater_than" , filter_str .lower ())
1108+ self .assertNotIn (">" , filter_str )
1109+ # Should contain the selected IDs (1 and 2)
1110+ self .assertIn ("1" , filter_str )
1111+ self .assertIn ("2" , filter_str )
0 commit comments