diff --git a/sqlx-core/src/type_checking.rs b/sqlx-core/src/type_checking.rs index 384d15f42c..5766124530 100644 --- a/sqlx-core/src/type_checking.rs +++ b/sqlx-core/src/type_checking.rs @@ -72,11 +72,17 @@ where match T::decode(value.as_ref()) { Ok(value) => Debug::fmt(&value, f), - Err(e) => f.write_fmt(format_args!( - "(error decoding SQL type {} as {}: {e:?})", - info.name(), - std::any::type_name::() - )), + Err(e) => { + if e.is::() { + f.write_str("NULL") + } else { + f.write_fmt(format_args!( + "(error decoding SQL type {} as {}: {e:?})", + info.name(), + std::any::type_name::() + )) + } + } } }, }