diff --git a/sqlx-core/src/sqlite/types/uuid.rs b/sqlx-core/src/sqlite/types/uuid.rs index 6c3a71db..0634a809 100644 --- a/sqlx-core/src/sqlite/types/uuid.rs +++ b/sqlx-core/src/sqlite/types/uuid.rs @@ -17,9 +17,9 @@ impl Type for Uuid { } } -impl<'q> Encode<'q, Sqlite> for &'q Uuid { +impl<'q> Encode<'q, Sqlite> for Uuid { fn encode_by_ref(&self, args: &mut Vec>) -> IsNull { - args.push(SqliteArgumentValue::Blob(Cow::Borrowed(self.as_bytes()))); + args.push(SqliteArgumentValue::Blob(Cow::Owned(self.as_bytes().to_vec()))); IsNull::No } @@ -38,7 +38,7 @@ impl Type for Hyphenated { } } -impl<'q> Encode<'q, Sqlite> for &'q Hyphenated { +impl<'q> Encode<'q, Sqlite> for Hyphenated { fn encode_by_ref(&self, args: &mut Vec>) -> IsNull { args.push(SqliteArgumentValue::Text(Cow::Owned(self.to_string()))); @@ -50,6 +50,7 @@ impl Decode<'_, Sqlite> for Hyphenated { fn decode(value: SqliteValueRef<'_>) -> Result { let uuid: Result = Uuid::parse_str(&value.text().map(ToOwned::to_owned)?).map_err(Into::into); + Ok(uuid?.to_hyphenated()) } }