From 9d6c5defd409da20e4b0375c8657def21a626b7d Mon Sep 17 00:00:00 2001 From: Nathan Roach Date: Thu, 25 Feb 2021 18:40:57 -0500 Subject: [PATCH] Adding derivation of any types for chrono types present in all of the featured sql types at compile time --- sqlx-core/src/any/types.rs | 97 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 97 insertions(+) diff --git a/sqlx-core/src/any/types.rs b/sqlx-core/src/any/types.rs index 26eeb889..a26173ce 100644 --- a/sqlx-core/src/any/types.rs +++ b/sqlx-core/src/any/types.rs @@ -55,3 +55,100 @@ impl_any_decode!(f64); impl_any_decode!(&'r str); impl_any_decode!(String); + +// Conversions for Time SQL types +// Type +#[cfg(all( + feature = "chrono", + any(feature = "mysql", feature = "sqlite", feature = "postgres"), + not(feature = "mssql") +))] +impl_any_type!(chrono::NaiveDate); +#[cfg(all( + feature = "chrono", + any(feature = "mysql", feature = "sqlite", feature = "postgres"), + not(feature = "mssql") +))] +impl_any_type!(chrono::DateTime); +#[cfg(all( + feature = "chrono", + any( feature = "sqlite", feature = "postgres"), + not(any(feature = "mysql", feature = "mssql")) +))] +impl_any_type!(chrono::DateTime); +#[cfg(all( + feature = "chrono", + any(feature = "mysql", feature = "postgres"), + not(any(feature = "mssql", feature = "sqlite")) +))] +impl_any_type!(chrono::NaiveDate); +#[cfg(all( + feature = "chrono", + any(feature = "mysql", feature = "postgres"), + not(any(feature = "mssql", feature = "sqlite")) +))] +impl_any_type!(chrono::NaiveTime); + +// Encode +#[cfg(all( + feature = "chrono", + any(feature = "mysql", feature = "sqlite", feature = "postgres"), + not(feature = "mssql") +))] +impl_any_encode!(chrono::NaiveDate); +#[cfg(all( + feature = "chrono", + any(feature = "mysql", feature = "sqlite", feature = "postgres"), + not(feature = "mssql") +))] +impl_any_encode!(chrono::DateTime); +#[cfg(all( + feature = "chrono", + any( feature = "sqlite", feature = "postgres"), + not(any(feature = "mysql", feature = "mssql")) +))] +impl_any_encode!(chrono::DateTime); +#[cfg(all( + feature = "chrono", + any(feature = "mysql", feature = "postgres"), + not(any(feature = "mssql", feature = "sqlite")) +))] +impl_any_encode!(chrono::NaiveDate); +#[cfg(all( + feature = "chrono", + any(feature = "mysql", feature = "postgres"), + not(any(feature = "mssql", feature = "sqlite")) +))] +impl_any_encode!(chrono::NaiveTime); + +// Decode +#[cfg(all( + feature = "chrono", + any(feature = "mysql", feature = "sqlite", feature = "postgres"), + not(feature = "mssql") +))] +impl_any_decode!(chrono::NaiveDate); +#[cfg(all( + feature = "chrono", + any(feature = "mysql", feature = "sqlite", feature = "postgres"), + not(feature = "mssql") +))] +impl_any_decode!(chrono::DateTime); +#[cfg(all( + feature = "chrono", + any( feature = "sqlite", feature = "postgres"), + not(any(feature = "mysql", feature = "mssql")) +))] +impl_any_decode!(chrono::DateTime); +#[cfg(all( + feature = "chrono", + any(feature = "mysql", feature = "postgres"), + not(any(feature = "mssql", feature = "sqlite")) +))] +impl_any_decode!(chrono::NaiveDate); +#[cfg(all( + feature = "chrono", + any(feature = "mysql", feature = "postgres"), + not(any(feature = "mssql", feature = "sqlite")) +))] +impl_any_decode!(chrono::NaiveTime);