From 2f875ab9df08cf5fd3fa2968ab6727fd800bb563 Mon Sep 17 00:00:00 2001 From: cody koeninger Date: Mon, 21 Oct 2024 18:27:56 -0500 Subject: [PATCH] fixes #3039 --- sqlx-mysql/src/types/uuid.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) 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) + } } }