Skip to content

Commit

Permalink
possible workaround for launchbadge#3039
Browse files Browse the repository at this point in the history
  • Loading branch information
koeninger-ironlight committed Oct 18, 2024
1 parent e74807a commit 92a0d9e
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions sqlx-mysql/src/types/uuid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,17 @@ impl Decode<'_, MySql> for Uuid {
// delegate to the &[u8] type to decode from MySQL
let bytes = <&[u8] as Decode<MySql>>::decode(value)?;

// construct a Uuid from the returned bytes
Uuid::from_slice(bytes).map_err(Into::into)
if bytes.len() == 16 {
// construct a Uuid from the returned bytes
Uuid::from_slice(bytes).map_err(Into::into)
} else {
// delegate to the &str type to decode from MySQL
let text = <&str as Decode<MySql>>::decode(value)?;

// parse a UUID from the text
Uuid::parse_str(text)
.map_err(Into::into)
}
}
}

Expand Down

0 comments on commit 92a0d9e

Please sign in to comment.