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

Regression in 1.9.1: Arrays & Hashes now become nil #48

Closed
wants to merge 1 commit into from
Closed

Regression in 1.9.1: Arrays & Hashes now become nil #48

wants to merge 1 commit into from

Conversation

zarqman
Copy link
Contributor

@zarqman zarqman commented Feb 16, 2020

Hi there! It appears that #47 (released in v1.9.1) causes a change from previous behavior.

In v1.9.0 & prior, converting .blank? -> nil was implicitly limited to Strings because those were conditional on if value.respond_to?(:strip).

#47 separated the .blank? test from respond_to?(:strip) which now causes non-Strings, such as Hashes and Arrays, to also be converted to nil.

This PR adds a check that an attribute is a String before running strip_string(), which matches the prior behavior.

Side note: this would likely allow many of the other respond_to?() tests to be dropped, but that seemed out of scope to be including here.

@swordray
Copy link

Breaks false too.

@rmm5t
Copy link
Owner

rmm5t commented Feb 16, 2020

@zarqman Thank you for this!! I adjusted your commit a bit and merged it into master here:
20a2aa9

I also just release the fix a v1.9.2. Sorry about the mishap.
https://rubygems.org/gems/strip_attributes

@rmm5t rmm5t closed this Feb 16, 2020
@zarqman zarqman deleted the ignore-non-strings branch February 16, 2020 22:01
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

Successfully merging this pull request may close these issues.

3 participants