fix(postgres): display SMALLINT/INT2 values instead of null (#118)
Add i16 to the type fallback chain in pg_value_to_json. The sqlx driver requires INT2 to be decoded as i16 specifically; the existing i64/i32 attempts silently failed, causing smallint values to fall through to null.
This commit is contained in:
parent
310468b44e
commit
148f892be0
|
|
@ -74,6 +74,7 @@ fn pg_value_to_json(row: &PgRow, idx: usize, type_name: &str) -> serde_json::Val
|
|||
.map(serde_json::Value::String)
|
||||
.or_else(|_| row.try_get::<i64, _>(idx).map(|v| serde_json::Value::Number(v.into())))
|
||||
.or_else(|_| row.try_get::<i32, _>(idx).map(|v| serde_json::Value::Number(v.into())))
|
||||
.or_else(|_| row.try_get::<i16, _>(idx).map(|v| serde_json::Value::Number(v.into())))
|
||||
.or_else(|_| {
|
||||
row.try_get::<f64, _>(idx).map(|v| {
|
||||
serde_json::Number::from_f64(v).map(serde_json::Value::Number).unwrap_or(serde_json::Value::Null)
|
||||
|
|
|
|||
Loading…
Reference in New Issue