hashie/hashie

[Informative] `deep_symbolize_keys` broken in Rails 7 with `Mash`

DerekYu177 opened this issue · 7 comments

Related tangentially to #514

In Rails ~> 6 versions, calling deep_symbolize_keys would instantiate a new Hash class when transforming keys in objects.

However, in Rails 7+, this has changed to instead be a self.class.new which would be a new Hashie::Mash. Digging into the accesses, it looks like by default internal keys are converted to strings, which renders the output of #deep_symbolize_keys unchanged.

I think this might be too small of an case to document to the readme, but I leave this as a known implementation bug to the authors.

We should probably raise in that case.

@DerekYu177 It would be awesome if you could turn this into a failing spec w/Rails 7 in hashie.

Opened.

This appears to be issue in Rails 7 when using deep_transform_keys for Trash and so I'd assume Dash as well.

@aflansburg Do you think you could contribute an integration spec for Rails 7 similar to https://github.com/hashie/hashie/tree/master/spec/integration/rails? (maybe that should be called rails6)

@dblock can do - for what it's worth I was able to get around this by doing

hashie_thing.to_hash.deep_transform_keys { |key| # transfoms }

Pending spec merged in #569, maybe someone wants to try and fix the issue?