Thank you, @jg-rp, for identifying this bug and helping to implement the fix.
Summary
This PR addresses a bug in the sum filter when handling arrays containing floats and thus yield a result that is a float.
Previously, the sum filter would return a BigDecimal, which would render in scientific notation, when summing floats. This behaviour was inconsistent with other math filters.
The change in this PR ensures that the sum filter returns a float instead of a BigDecimal when summing floats, aligning its behaviour with other math filters.
Thank you, @jg-rp, for identifying this bug and helping to implement the fix.
Summary
This PR addresses a bug in the
sum
filter when handling arrays containing floats and thus yield a result that is a float.Previously, the
sum
filter would return aBigDecimal
, which would render in scientific notation, when summing floats. This behaviour was inconsistent with other math filters.The change in this PR ensures that the
sum
filter returns a float instead of aBigDecimal
when summing floats, aligning its behaviour with other math filters.For example:
https://github.com/Shopify/liquid/blob/0b9318222bcc09681e52fd5b8e70262274e673bf/lib/liquid/standardfilters.rb#L908-L911
Changes
sum
filter inlib/liquid/standardfilters.rb
to convert BigDecimal results to floats when summing floats.test/integration/standard_filter_test.rb
to verify the correct behaviour of thesum
filter when handling floats.