diff --git a/sqlx-mysql/src/types/uuid.rs b/sqlx-mysql/src/types/uuid.rs index 53adfac0e3..da05072f83 100644 --- a/sqlx-mysql/src/types/uuid.rs +++ b/sqlx-mysql/src/types/uuid.rs @@ -33,8 +33,15 @@ impl Decode<'_, MySql> for Uuid { // delegate to the &[u8] type to decode from MySQL let bytes = <&[u8] as Decode>::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 { + let text = std::str::from_utf8(bytes)?; + + // parse a UUID from the text + Uuid::parse_str(text).map_err(Into::into) + } } }