Skip to content

Commit

Permalink
Fix UnexpectedNullError when deserializing (Null,NotNull) into Option…
Browse files Browse the repository at this point in the history
…<(a,b)>

Resolves #2274
  • Loading branch information
Ten0 committed Jan 22, 2020
1 parent bd349ce commit ea89edb
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion diesel/src/type_impls/option.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,16 @@ where
row.advance(fields_needed);
Ok(None)
} else {
T::build_from_row(row).map(Some)
match T::build_from_row(row) {
Ok(v) => Ok(Some(v)),
Err(e) => {
if e.is::<UnexpectedNullError>() {
Ok(None)
} else {
Err(e)
}
}
}
}
}
}
Expand Down

0 comments on commit ea89edb

Please sign in to comment.