Skip to content

Commit 8b29f37

Browse files
authored
Merge branch 'master' into inspect-associations-for-computing-type
2 parents 50b05ab + 9f47275 commit 8b29f37

3 files changed

Lines changed: 12 additions & 2 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
## Unreleased
44

5-
## 1.23.0
65
- [#403](https://github.com/JsonApiClient/json_api_client/pull/403) - Feature: Use the association options to lookup relationship class
6+
- [#406](https://github.com/JsonApiClient/json_api_client/pull/406) - Deep-merge nested `additional_params`
77

88
## 1.21.1
99
- [#404](https://github.com/JsonApiClient/json_api_client/pull/404) - Expose NotFound json errors

lib/json_api_client/query/builder.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff 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, [] ),

test/unit/query_builder_test.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff 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'}})

0 commit comments

Comments
 (0)