You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Decimal precision does not match when converting a PgNumeric to a rust_decimal::Decimal. This is corrected by calling .normalize() on rust_decimal::Decimal.
We encountered this problem when noticed that passing BigDecimal value from postgres to JSON always producing something like 1234.600, which is technically correct and shouldn't affect anything, but still annoying. I believe rust_decimal and bigdecimal features should call normalize() (normalized() for bigdecimal) at the end of TryFrom. But this will obviously add some overhead.
Is there a workaround for this? I was thinking that I could use serde's custom deserializer, but that doesn't seem to work (I don't think sqlx deserializes into the struct field.) However I was able to serialize the field which has big decimal to 2.
Bug Description
Decimal precision does not match when converting a
PgNumeric
to arust_decimal::Decimal
. This is corrected by calling.normalize()
onrust_decimal::Decimal
.Minimal Reproduction
Info
rustc --version
: rustc 1.65.0 (897e37553 2022-11-02)The text was updated successfully, but these errors were encountered: