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
Rails 6.1 regression issue with big decimals precision #42302
Comments
It seems the issue is caused by this diff : 7905bdf#diff-cda12a0b7fe1607d710c06d2be6dc0e09d10a8f272a7156a70e5e1003dd40e8c diff activesupport/lib/active_support/number_helper/number_to_rounded_converter.rb
end
formatted_string =
- if BigDecimal === rounded_number && rounded_number.finite?
+ if rounded_number.nan? || rounded_number.infinite? || rounded_number == rounded_number.to_i
+ "%00.#{precision}f" % rounded_number
+ else
s = rounded_number.to_s("F")
s << "0" * precision
a, b = s.split(".", 2)
a << "."
a << b[0, precision]
- else
- "%00.#{precision}f" % rounded_number
end
else
formatted_string = rounded_number Let consider that
With the new behaviour,
|
@tom-lord Since you added this back in #38148 would you mind taking a look? 🙇 /cc @rafaelfranca |
Ah yes, how odd!...
There must be some missing test coverage around this scenario. I remember changing that line to better encapsulate handing BTW this should probably be tagged as |
Thank you for the fix, are you considering releasing a patch release for the 6.1 branch? |
I've backported it here: #42374 Just waiting for CI to pass. |
Steps to reproduce
In rails console:
It seems to me that this commit might be at fault: 7905bdf (not checked it though, just ran git blame on relevant classes and found it)
Expected behavior
in context :
Actual behavior
in context :
System configuration
Rails version: 6.1.3.1
Ruby version: ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [x86_64-linux]
The text was updated successfully, but these errors were encountered: