File tree Expand file tree Collapse file tree
lib/json_api_client/query Expand file tree Collapse file tree Original file line number Diff line number Diff line change 22
33## Unreleased
44
5+ - [ #406 ] ( https://github.com/JsonApiClient/json_api_client/pull/406 ) - Deep-merge nested ` additional_params `
6+
57## 1.21.1
68- [ #404 ] ( https://github.com/JsonApiClient/json_api_client/pull/404 ) - Expose NotFound json errors
79- [ #378 ] ( https://github.com/JsonApiClient/json_api_client/pull/378 ) - Add the ability to create a subclass of JsonApiClient::Resource to have a modified id method
Original file line number Diff line number Diff line change @@ -136,7 +136,7 @@ def _new_scope( opts = {} )
136136 primary_key : opts . fetch ( :primary_key , @primary_key ) ,
137137 pagination_params : @pagination_params . merge ( opts . fetch ( :pagination_params , { } ) ) ,
138138 path_params : @path_params . merge ( opts . fetch ( :path_params , { } ) ) ,
139- additional_params : @additional_params . merge ( opts . fetch ( :additional_params , { } ) ) ,
139+ additional_params : @additional_params . deep_merge ( opts . fetch ( :additional_params , { } ) ) ,
140140 filters : @filters . merge ( opts . fetch ( :filters , { } ) ) ,
141141 includes : @includes + opts . fetch ( :includes , [ ] ) ,
142142 orders : @orders + opts . fetch ( :orders , [ ] ) ,
Original file line number Diff line number Diff line change @@ -122,6 +122,16 @@ def test_can_specify_additional_params
122122 Article . with_params ( sort : "foo" ) . to_a
123123 end
124124
125+ def test_can_merge_nested_additional_params
126+ stub_request ( :get , "http://example.com/articles" )
127+ . with ( query : { top : { foos : 1 , bars : 2 } } )
128+ . to_return ( headers : { content_type : "application/vnd.api+json" } , body : {
129+ data : [ ]
130+ } . to_json )
131+
132+ Article . with_params ( top : { foos : 1 } ) . with_params ( top : { bars : 2 } ) . to_a
133+ end
134+
125135 def test_can_select_fields
126136 stub_request ( :get , "http://example.com/articles" )
127137 . with ( query : { fields : { articles : 'title,body' } } )
You can’t perform that action at this time.
0 commit comments