JsonApiClient / json_api_client

Build client libraries compliant with specification defined by jsonapi.org
MIT License
362 stars 186 forks source link

Deep-merge nested additional_params (i.e. chained use of `with_params` with nested arguments) #406

Closed tom-lord closed 11 months ago

tom-lord commented 1 year ago

Before, calling:

Article.with_params(top: {foos: 1}).with_params(top: {bars: 2})

Would trigger a query:

.with(query: {top: {bars: 2}})

(i.e. the foos: 1 vanished), because the code was calling merge on the parameters. In other words, it was doing:

{top: {foos: 1}}.merge(top: {bars: 2})
=> {:top=>{:bars=>2}}

With this fix, the builder correctly merges nested parameters:

{top: {foos: 1}}.deep_merge(top: {bars: 2})
=> {:top=>{:foos => 1, :bars=>2}}
tom-lord commented 1 year ago

@gaorlov I've rebased master and added to the CHANGELOG.

Github says approval from a maintainer is required to get tests running.

gaorlov commented 11 months ago

hello! Sorry about the delay! this is now available in 1.22.0 Thank you so much for your contribution!