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

Possible regression of HWIA#transform_keys in rails 5.2.0.rc1 #32007

Closed
eitoball opened this issue Feb 15, 2018 · 2 comments
Closed

Possible regression of HWIA#transform_keys in rails 5.2.0.rc1 #32007

eitoball opened this issue Feb 15, 2018 · 2 comments

Comments

@eitoball
Copy link
Contributor

Steps to reproduce

  1. Use ruby 2.5.0
  2. Create an instance of HashWithIndifferentAccess
  3. Convert keys to Symbol
hsh = {a: 1}.with_indifferent_access
hsh = hsh.transform_keys { |_| :b }

Expected behavior

Return some value if given key exists in String and Symbol. In example above, hsh['b'] and hsh[:b] should return 1.

Actual behavior

Return nil

I think than since this commit, HWIA#transform_keys returns a HWIA, but it uses ruby's Hash#transform_keys! on ruby 2.5.0.

System configuration

Rails version: Rails 5.2.0.rc1

Ruby version: ruby 2.5.0p0 (2017-12-25 revision 61468) [x86_64-darwin15]

@rafaelfranca
Copy link
Member

This feel more like an issue with Ruby 2.5.0 than with Rails. Can you report to Ruby? It looks like that their transform_keys = don't use the []= method to set the value.

@eitoball
Copy link
Contributor Author

Can you report to Ruby? It looks like that their transform_keys = don't use the []= method to set the value.

I will report it ruby-core. But I don't think that it is necessary to use []= to convert keys.

rafaelfranca added a commit that referenced this issue Feb 17, 2018
Make sure that when transforming the keys of a HashWithIndifferentAccess
we can still access with indifferent access in Ruby 2.5.

Closes #32007.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants