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
Unable to store BigDecimal with negative scale in NUMERIC(19,6) column #3263
Comments
Workaround: Call setScale(0) before storing the value or use DECIMAL as column type. |
H2 should convert passed |
Where in the code does that happen? |
Stack trace of the error:
At no point is code which tries to fix the scale. Note: Fixing the scale is a good idea because right now, numerically identical BigDecimal instances with different internal state will create different cache entries. |
I meant this needs to be implemented in |
Thanks for the quick fix! |
I have a BigDecimal with the value "3.81E+3". The internal state of the instance is:
toPlainString() prints "3810".
When I try to store that into a NUMERIC(19,6) column, I get an exception with v2.0 of H2 because ValueNumeric was changed in katzyn@8bdb209#diff-2be2d3cabf9b48cf9d45ab2ca2c8f9fef25aaa172d4ed7d4ba39ddbc68a174f2 to check for negative scales.
I think this is a misconception how BigDecimal works in Java. From the documenation:
Please remove the check and add a unit test: Try to store
BigDecimal.ONE.scaleByPowerOfTen(3)
The text was updated successfully, but these errors were encountered: