Skip to content

Commit 92a0d9e

Browse files
possible workaround for launchbadge#3039
1 parent e74807a commit 92a0d9e

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

sqlx-mysql/src/types/uuid.rs

+11-2
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,17 @@ impl Decode<'_, MySql> for Uuid {
3333
// delegate to the &[u8] type to decode from MySQL
3434
let bytes = <&[u8] as Decode<MySql>>::decode(value)?;
3535

36-
// construct a Uuid from the returned bytes
37-
Uuid::from_slice(bytes).map_err(Into::into)
36+
if bytes.len() == 16 {
37+
// construct a Uuid from the returned bytes
38+
Uuid::from_slice(bytes).map_err(Into::into)
39+
} else {
40+
// delegate to the &str type to decode from MySQL
41+
let text = <&str as Decode<MySql>>::decode(value)?;
42+
43+
// parse a UUID from the text
44+
Uuid::parse_str(text)
45+
.map_err(Into::into)
46+
}
3847
}
3948
}
4049

0 commit comments

Comments
 (0)