fix(sql): split up datatypes more granular, fixes #462 (#608)

pull/609/head
Fabian-Lars 2 years ago committed by GitHub
parent 5b85dd22c7
commit 0190f68f1d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -17,14 +17,35 @@ pub(crate) fn to_json(v: PgValueRef) -> Result<JsonValue, Error> {
JsonValue::Null
}
}
"FLOAT4" | "FLOAT8" => {
"FLOAT4" => {
if let Ok(v) = ValueRef::to_owned(&v).try_decode::<f32>() {
JsonValue::from(v)
} else {
JsonValue::Null
}
}
"FLOAT8" => {
if let Ok(v) = ValueRef::to_owned(&v).try_decode::<f64>() {
JsonValue::from(v)
} else {
JsonValue::Null
}
}
"INT2" | "INT4" | "INT8" => {
"INT2" => {
if let Ok(v) = ValueRef::to_owned(&v).try_decode::<i16>() {
JsonValue::Number(v.into())
} else {
JsonValue::Null
}
}
"INT4" => {
if let Ok(v) = ValueRef::to_owned(&v).try_decode::<i32>() {
JsonValue::Number(v.into())
} else {
JsonValue::Null
}
}
"INT8" => {
if let Ok(v) = ValueRef::to_owned(&v).try_decode::<i64>() {
JsonValue::Number(v.into())
} else {

Loading…
Cancel
Save