Skip to content

MONGOID-5221/5222: Fix mongoization + demongoization of non-empty string as Integer/Float #5220

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

Conversation

johnnyshields
Copy link
Contributor

@johnnyshields johnnyshields commented Apr 13, 2022

This is a partial fix for MONGOID-5222 and MONGOID-5221

@p-mongo
Copy link
Contributor

p-mongo commented Apr 13, 2022

The ticket is for demongoization, this PR changes mongoization and demongoization. The to_i/to_f calls should remain as they were, they are not equivalent to calling Integer()/Float().

@johnnyshields
Copy link
Contributor Author

johnnyshields commented Apr 13, 2022

@p-mongo I've clarified in the ticket the behavior should be identical for both mongoization and demongoization. There's no reason to convert the string "Foobar" to 0; it should be nil as it is non-sensical.

Note that :demongoize is aliased to :mongoize for these classes, and this is further reason to keep it consistent.

(BigDecimal by the way already does the correct thing both mongoization and demongoization)

@johnnyshields johnnyshields changed the title MONGOID-5286: Fix mongoization of non-empty string as Integer/Float MONGOID-5221/5222: Fix mongoization of non-empty string as Integer/Float Apr 19, 2022
@johnnyshields johnnyshields changed the title MONGOID-5221/5222: Fix mongoization of non-empty string as Integer/Float MONGOID-5221/5222: Fix mongoization + demongoization of non-empty string as Integer/Float Apr 23, 2022
…6-fix-mongoization-of-int-float-non-emty-string
@johnnyshields
Copy link
Contributor Author

@p-mongo please consider merging this at this time. While I appreciate there is an epic to fully review mongoization/demongoization, this PR is a "quick win" for a Float/Integer which are very commonly used.

@p-mongo
Copy link
Contributor

p-mongo commented May 20, 2022

I responded in https://jira.mongodb.org/browse/MONGOID-5222.

@johnnyshields johnnyshields deleted the MONGOID-5286-fix-mongoization-of-int-float-non-emty-string branch June 18, 2022 02:25
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.

2 participants