Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Informative] deep_symbolize_keys broken in Rails 7 with Mash #559

Open
DerekYu177 opened this issue Mar 23, 2022 · 7 comments
Open

[Informative] deep_symbolize_keys broken in Rails 7 with Mash #559

DerekYu177 opened this issue Mar 23, 2022 · 7 comments
Labels

Comments

@DerekYu177
Copy link

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.

@dblock
Copy link
Member

dblock commented Mar 23, 2022

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.

@DerekYu177
Copy link
Author

Opened.

MothOnMars added a commit to MothOnMars/search-gov that referenced this issue Sep 20, 2022
MothOnMars added a commit to MothOnMars/search-gov that referenced this issue Sep 21, 2022
MothOnMars added a commit to MothOnMars/search-gov that referenced this issue Sep 21, 2022
MothOnMars added a commit to MothOnMars/search-gov that referenced this issue Sep 27, 2022
@aflansburg
Copy link
Contributor

aflansburg commented Nov 3, 2022

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

@dblock
Copy link
Member

dblock commented Nov 4, 2022

@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)

@aflansburg
Copy link
Contributor

@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 }

@aflansburg
Copy link
Contributor

@dblock dblock changed the title [Informative] deep_symbolize_keys will no longer work in Rails 7 with Mash [Informative] deep_symbolize_keys broken in Rails 7 with Mash Dec 6, 2022
@dblock
Copy link
Member

dblock commented Dec 6, 2022

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

@dblock dblock added the bug? label Aug 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants