Skip to content

Commit

Permalink
Update sqlx-core/src/any/row.rs
Browse files Browse the repository at this point in the history
Co-authored-by: Yota Toyama <raviqqe@gmail.com>
  • Loading branch information
abonander and raviqqe committed Jul 14, 2022
1 parent 1a2cc7b commit 49bad74
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions sqlx-core/src/any/row.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,19 +79,14 @@ impl Row for AnyRow {
T: Decode<'r, Self::Database> + Type<Self::Database>,
{
let value = self.try_get_raw(&index)?;
let ty = value.type_info();

if !value.is_null() {
let ty = value.type_info();

if !ty.is_null() && !T::compatible(&ty) {
return Err(Error::ColumnDecode {
index: format!("{:?}", index),
source: mismatched_types::<T>(&ty),
});
}
if !value.is_null() && !ty.is_null() && !T::compatible(&ty) {
Err(mismatched_types::<T>(&ty))
} else {
T::decode(value)
}

T::decode(value).map_err(|source| Error::ColumnDecode {
.map_err(|source| Error::ColumnDecode {
index: format!("{:?}", index),
source,
})
Expand Down

0 comments on commit 49bad74

Please sign in to comment.