mirror of
https://github.com/t8y2/dbx.git
synced 2026-10-22 08:47:26 +00:00
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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user