From 18acba23588deb1a1d39516b7b0ca6964f1432a6 Mon Sep 17 00:00:00 2001 From: Guy Lapid Date: Thu, 6 May 2021 15:06:16 +0300 Subject: [PATCH] Added any types for binary blobs and chrono NaiveDateTime --- sqlx-core/src/any/types.rs | 56 +++++++++++++++++++++++++++++++++++++- 1 file changed, 55 insertions(+), 1 deletion(-) diff --git a/sqlx-core/src/any/types.rs b/sqlx-core/src/any/types.rs index 9f5d11f256..124517fabf 100644 --- a/sqlx-core/src/any/types.rs +++ b/sqlx-core/src/any/types.rs @@ -56,6 +56,43 @@ impl_any_decode!(f64); impl_any_decode!(&'r str); impl_any_decode!(String); +// Conversions for Blob SQL types +// Type +#[cfg(all( + any(feature = "mysql", feature = "sqlite", feature = "postgres"), + not(feature = "mssql") +))] +impl_any_type!([u8]); +#[cfg(all( + any(feature = "mysql", feature = "sqlite", feature = "postgres"), + not(feature = "mssql") +))] +impl_any_type!(Vec); + +// Encode +#[cfg(all( + any(feature = "mysql", feature = "sqlite", feature = "postgres"), + not(feature = "mssql") +))] +impl_any_encode!(&'q [u8]); +#[cfg(all( + any(feature = "mysql", feature = "sqlite", feature = "postgres"), + not(feature = "mssql") +))] +impl_any_encode!(Vec); + +// Decode +#[cfg(all( + any(feature = "mysql", feature = "sqlite", feature = "postgres"), + not(feature = "mssql") +))] +impl_any_decode!(&'r [u8]); +#[cfg(all( + any(feature = "mysql", feature = "sqlite", feature = "postgres"), + not(feature = "mssql") +))] +impl_any_decode!(Vec); + // Conversions for Time SQL types // Type #[cfg(all( @@ -70,7 +107,12 @@ impl_any_type!(chrono::NaiveDate); not(feature = "mssql") ))] impl_any_type!(chrono::NaiveTime); - +#[cfg(all( + feature = "chrono", + any(feature = "mysql", feature = "sqlite", feature = "postgres"), + not(feature = "mssql") +))] +impl_any_type!(chrono::NaiveDateTime); #[cfg(all( feature = "chrono", any(feature = "mysql", feature = "sqlite", feature = "postgres"), @@ -102,6 +144,12 @@ impl_any_encode!(chrono::NaiveTime); any(feature = "mysql", feature = "sqlite", feature = "postgres"), not(feature = "mssql") ))] +impl_any_encode!(chrono::NaiveDateTime); +#[cfg(all( + feature = "chrono", + any(feature = "mysql", feature = "sqlite", feature = "postgres"), + not(feature = "mssql") +))] impl_any_encode!(chrono::DateTime); #[cfg(all( feature = "chrono", @@ -128,6 +176,12 @@ impl_any_decode!(chrono::NaiveTime); any(feature = "mysql", feature = "sqlite", feature = "postgres"), not(feature = "mssql") ))] +impl_any_decode!(chrono::NaiveDateTime); +#[cfg(all( + feature = "chrono", + any(feature = "mysql", feature = "sqlite", feature = "postgres"), + not(feature = "mssql") +))] impl_any_decode!(chrono::DateTime); #[cfg(all( feature = "chrono",