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:
t8y2 2026-05-06 19:06:11 +08:00
parent 310468b44e
commit 148f892be0
1 changed files with 1 additions and 0 deletions

View File

@ -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)