Skip to content

Commit

Permalink
fix: Option decoding in any driver (launchbadge#3172)
Browse files Browse the repository at this point in the history
  • Loading branch information
pxp9 authored and jayy-lmao committed Jun 6, 2024
1 parent 0b62ac1 commit 4ec9f48
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion sqlx-core/src/any/type_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ pub enum AnyTypeInfoKind {

impl TypeInfo for AnyTypeInfo {
fn is_null(&self) -> bool {
false
self.kind == Null
}

fn name(&self) -> &str {
Expand Down
4 changes: 2 additions & 2 deletions sqlx-core/src/any/value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ impl Value for AnyValue {
}

fn is_null(&self) -> bool {
false
matches!(self.kind, AnyValueKind::Null)
}
}

Expand Down Expand Up @@ -120,6 +120,6 @@ impl<'a> ValueRef<'a> for AnyValueRef<'a> {
}

fn is_null(&self) -> bool {
false
matches!(self.kind, AnyValueKind::Null)
}
}
4 changes: 2 additions & 2 deletions sqlx-core/src/types/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
//! An `Option<T>` 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")))]
Expand Down Expand Up @@ -234,6 +234,6 @@ impl<T: Type<DB>, DB: Database> Type<DB> for Option<T> {
}

fn compatible(ty: &DB::TypeInfo) -> bool {
<T as Type<DB>>::compatible(ty)
ty.is_null() || <T as Type<DB>>::compatible(ty)
}
}

0 comments on commit 4ec9f48

Please sign in to comment.