You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Looking at https://github.com/JsonApiClient/json_api_client/pull/386/files, I see that there's shift towards using HashWithIndiferentAccess, however, this change causes a wrong serialization when calling as_json_api. Which is causing a lot of tests to break on my end. Here's an example:
The previous symbolize_keys approach would serialize like this:
resource.as_json_api{"type"=>"resources","relationships"=>{"location"=>{"data"=>{"type"=>"locations","id"=>"1"}}},"attributes"=>{"arrival-time"=>"...","full-name"=>"a full name","email"=>nil,"user-data"=>[{"field"=>"color","value"=>"blue"}],"private-notes"=>nil,"guests"=>nil,"phone"=>nil}}
but with the new with_indiferent_access approach it serializes like this:
resource.as_json_api{"type"=>"resources","relationships"=>{"location"=>{"data"=>{"type"=>"locations","id"=>"1"}}},"attributes"=>{"arrival-time"=>"...","full-name"=>"a full name","email"=>nil,"user-data"=>[{"field"=>"color","value"=>"blue"}],"private-notes"=>nil,"additional-guests"=>nil,"phone"=>nil,"location"=>#<Models::Location:@attributes={"type"=>"locations", "id"=>"1", "address_line_one"=>nil, "address_line_two"=>nil}>}}
It is adding location as an attribute and set it equals to the value of to_s. which is derived from using with_indiferent_access.
These results I got from getting 1.20.0 and manually reverting the symbolize keys change.
Would really appreciate any guidance here, although it seems that the version 1.19.0 added some unexpected behavior.
Thanks in advance for any help/comments
The text was updated successfully, but these errors were encountered:
it is definitely weird, that it would take the relationships passed in .new as attributes, but seems consistent with the .with_indifferent_access change.
thebluber
added a commit
to test-IO/json_api_client
that referenced
this issue
Mar 29, 2022
Looking at https://github.com/JsonApiClient/json_api_client/pull/386/files, I see that there's shift towards using HashWithIndiferentAccess, however, this change causes a wrong serialization when calling
as_json_api
. Which is causing a lot of tests to break on my end. Here's an example:The previous
symbolize_keys
approach would serialize like this:but with the new
with_indiferent_access
approach it serializes like this:It is adding
location
as an attribute and set it equals to the value ofto_s
. which is derived from usingwith_indiferent_access
.These results I got from getting 1.20.0 and manually reverting the symbolize keys change.
Would really appreciate any guidance here, although it seems that the version 1.19.0 added some unexpected behavior.
Thanks in advance for any help/comments
The text was updated successfully, but these errors were encountered: