We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent e74807a commit 92a0d9eCopy full SHA for 92a0d9e
sqlx-mysql/src/types/uuid.rs
@@ -33,8 +33,17 @@ impl Decode<'_, MySql> for Uuid {
33
// delegate to the &[u8] type to decode from MySQL
34
let bytes = <&[u8] as Decode<MySql>>::decode(value)?;
35
36
- // construct a Uuid from the returned bytes
37
- Uuid::from_slice(bytes).map_err(Into::into)
+ if bytes.len() == 16 {
+ // 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
+ }
47
}
48
49
0 commit comments