diff --git a/sqlx-core/src/any/type_info.rs b/sqlx-core/src/any/type_info.rs index a7eec4a953..0879b333ca 100644 --- a/sqlx-core/src/any/type_info.rs +++ b/sqlx-core/src/any/type_info.rs @@ -31,7 +31,7 @@ pub enum AnyTypeInfoKind { impl TypeInfo for AnyTypeInfo { fn is_null(&self) -> bool { - false + self.kind == Null } fn name(&self) -> &str { diff --git a/sqlx-core/src/any/value.rs b/sqlx-core/src/any/value.rs index 2ff63bc7d5..3dff058b24 100644 --- a/sqlx-core/src/any/value.rs +++ b/sqlx-core/src/any/value.rs @@ -92,7 +92,7 @@ impl Value for AnyValue { } fn is_null(&self) -> bool { - false + matches!(self.kind, AnyValueKind::Null) } } @@ -120,6 +120,6 @@ impl<'a> ValueRef<'a> for AnyValueRef<'a> { } fn is_null(&self) -> bool { - false + matches!(self.kind, AnyValueKind::Null) } } diff --git a/sqlx-core/src/types/mod.rs b/sqlx-core/src/types/mod.rs index 7e8df217a2..3fb1247827 100644 --- a/sqlx-core/src/types/mod.rs +++ b/sqlx-core/src/types/mod.rs @@ -18,7 +18,7 @@ //! An `Option` represents a potentially `NULL` value from SQL. //! -use crate::database::Database; +use crate::{database::Database, type_info::TypeInfo}; #[cfg(feature = "bstr")] #[cfg_attr(docsrs, doc(cfg(feature = "bstr")))] @@ -234,6 +234,6 @@ impl, DB: Database> Type for Option { } fn compatible(ty: &DB::TypeInfo) -> bool { - >::compatible(ty) + ty.is_null() || >::compatible(ty) } }