mirror of
https://github.com/launchbadge/sqlx.git
synced 2025-12-29 21:00:54 +00:00
fix: audit sqlx_postgres::types::rust_decimal for casts involving sign loss
This commit is contained in:
parent
ea2926135f
commit
cac914fa21
@ -50,6 +50,9 @@ impl TryFrom<&'_ PgNumeric> for Decimal {
|
||||
// Postgres returns an empty digit array for 0
|
||||
return Ok(Decimal::ZERO);
|
||||
}
|
||||
|
||||
let scale = u32::try_from(scale)
|
||||
.map_err(|_| format!("invalid scale value for Pg NUMERIC: {scale}"))?;
|
||||
|
||||
let mut value = Decimal::ZERO;
|
||||
|
||||
@ -73,7 +76,7 @@ impl TryFrom<&'_ PgNumeric> for Decimal {
|
||||
PgNumericSign::Negative => value.set_sign_negative(true),
|
||||
}
|
||||
|
||||
value.rescale(scale as u32);
|
||||
value.rescale(scale);
|
||||
|
||||
Ok(value)
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user