From 187b7481e9cc6a79ee926dcc629752ee517ea3ee Mon Sep 17 00:00:00 2001 From: Ryan Leckey Date: Fri, 18 Dec 2020 21:26:00 -0800 Subject: [PATCH] fix(sqlite): implement Encode on Uuid and Hyphenated not references to them --- sqlx-core/src/sqlite/types/uuid.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) 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()) } }