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
Error with PostgreSQL and high scale #219
Comments
Oh, and of course we need some values inserted before running this: insert into sql_load_test."Test" (id, fl, fl2) values (1, 1.2, 1.2); |
Thanks for raising this issue @pimeys - I'll take a look at this ASAP. My guess is that it's related to retaining scale upon reading values. |
Check the PR for even easier test to reveal the bug. |
Overflow has been sourced to the line: https://github.com/paupino/rust-decimal/blob/master/src/postgres.rs#L99 |
So is the underflow rounding what happens with 1.1 right now? We can survive, and I found this just by accident by updating decimal and our default scale being that big... :) |
Not quite, but it was implicitly normalizing the number. One of the changes in 1.2 was to retain the postgres scale. For example: if the database stored the number In 1.1 the number I can get a fix out for the issue you're having pretty quickly, and would likely generate a follow up issue for the broader fix (i.e. if scale was 100 etc). |
Yep, I'll have a test suite here that will show if the fix works quite easily. Would also like to follow the latest versions from all the crates in quaint/prisma, so ping me when there's a fix available! Thank you. |
Tested this PR and it works fine for numbers such as 1.2 with a large scale (30). Although another test with pi (3.141592653589793238462643383279) of course cuts the last two numbers off when writing and crashes with
when reading. |
Hi @pimeys - it may be worth taking another look at |
Had quite a busy week. Yeah, this works. Thanks! |
I'm experiencing a hard crash reading a decimal value from a postgres table using a high-scale numeric type. The error happens with
rust_decimal
version 1.2.0, version 1.1.0 works fine. We can replicate the issue in all major postgres versions from 9 to 12.My schema looks like this:
And we can reproduce this with a simple test program:
Cargo.toml:
main.rs:
The program output is here:
To save looking into the large backtrace, the bug line is this and happens in the
pow
function call (overflow).The text was updated successfully, but these errors were encountered: