fix: handle nullable values by printing NULL instead of panicking (#3686)
This commit is contained in:
parent
838a239a2c
commit
f6d2fa3a3d
1 changed files with 11 additions and 5 deletions
|
@ -72,11 +72,17 @@ where
|
||||||
|
|
||||||
match T::decode(value.as_ref()) {
|
match T::decode(value.as_ref()) {
|
||||||
Ok(value) => Debug::fmt(&value, f),
|
Ok(value) => Debug::fmt(&value, f),
|
||||||
Err(e) => f.write_fmt(format_args!(
|
Err(e) => {
|
||||||
"(error decoding SQL type {} as {}: {e:?})",
|
if e.is::<crate::error::UnexpectedNullError>() {
|
||||||
info.name(),
|
f.write_str("NULL")
|
||||||
std::any::type_name::<T>()
|
} else {
|
||||||
)),
|
f.write_fmt(format_args!(
|
||||||
|
"(error decoding SQL type {} as {}: {e:?})",
|
||||||
|
info.name(),
|
||||||
|
std::any::type_name::<T>()
|
||||||
|
))
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue