diff --git a/sqlx-core/src/any/types.rs b/sqlx-core/src/any/types.rs index 0a35115def..6236e83ab0 100644 --- a/sqlx-core/src/any/types.rs +++ b/sqlx-core/src/any/types.rs @@ -151,3 +151,11 @@ mod decimal_types { impl_any_encode!(Decimal); impl_any_decode!(Decimal); } + +#[cfg(feature = "uuid")] +mod uuid_types { + use uuid::Uuid; + impl_any_type!(Uuid); + impl_any_encode!(Uuid); + impl_any_decode!(Uuid); +} diff --git a/tests/any/any.rs b/tests/any/any.rs index a753b703a1..ed14cf3354 100644 --- a/tests/any/any.rs +++ b/tests/any/any.rs @@ -112,6 +112,24 @@ async fn it_has_json() -> anyhow::Result<()> { Ok(()) } +#[cfg(feature = "uuid")] +#[sqlx_macros::test] +async fn it_has_uuid() -> anyhow::Result<()> { + use sqlx_oldapi::types::Uuid; + assert_eq!( + Uuid::parse_str("123e4567-e89b-12d3-a456-426614174000")?, + get_val::(if cfg!(feature = "mssql") { + "CONVERT(uniqueidentifier, '123e4567-e89b-12d3-a456-426614174000')" + } else if cfg!(feature = "postgres") { + "'123e4567-e89b-12d3-a456-426614174000'::uuid" + } else { + "x'123e4567e89b12d3a456426614174000'" + }) + .await? + ); + Ok(()) +} + #[sqlx_macros::test] async fn it_pings() -> anyhow::Result<()> { let mut conn = new::().await?;