Skip to content

Commit

Permalink
Added any types for binary blobs and chrono NaiveDateTime
Browse files Browse the repository at this point in the history
  • Loading branch information
guylapid authored and mehcode committed May 21, 2021
1 parent 0acb0e5 commit 18acba2
Showing 1 changed file with 55 additions and 1 deletion.
56 changes: 55 additions & 1 deletion sqlx-core/src/any/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<u8>);

// 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<u8>);

// 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<u8>);

// Conversions for Time SQL types
// Type
#[cfg(all(
Expand 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"),
Expand Down Expand Up @@ -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<chrono::offset::Utc>);
#[cfg(all(
feature = "chrono",
Expand All @@ -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<chrono::offset::Utc>);
#[cfg(all(
feature = "chrono",
Expand Down

0 comments on commit 18acba2

Please sign in to comment.