mirror of
https://github.com/launchbadge/sqlx.git
synced 2026-03-19 16:44:07 +00:00
refactor: lift type mappings into driver crates (#2970)
Motivated by #2917
This commit is contained in:
@@ -65,6 +65,7 @@ mod query_result;
|
||||
mod row;
|
||||
mod statement;
|
||||
mod transaction;
|
||||
mod type_checking;
|
||||
mod type_info;
|
||||
pub mod types;
|
||||
mod value;
|
||||
|
||||
46
sqlx-sqlite/src/type_checking.rs
Normal file
46
sqlx-sqlite/src/type_checking.rs
Normal file
@@ -0,0 +1,46 @@
|
||||
#[allow(unused_imports)]
|
||||
use sqlx_core as sqlx;
|
||||
|
||||
use crate::Sqlite;
|
||||
|
||||
// f32 is not included below as REAL represents a floating point value
|
||||
// stored as an 8-byte IEEE floating point number (i.e. an f64)
|
||||
// For more info see: https://www.sqlite.org/datatype3.html#storage_classes_and_datatypes
|
||||
impl_type_checking!(
|
||||
Sqlite {
|
||||
bool,
|
||||
i32,
|
||||
i64,
|
||||
f64,
|
||||
String,
|
||||
Vec<u8>,
|
||||
|
||||
#[cfg(all(feature = "chrono", not(feature = "time")))]
|
||||
sqlx::types::chrono::NaiveDate,
|
||||
|
||||
#[cfg(all(feature = "chrono", not(feature = "time")))]
|
||||
sqlx::types::chrono::NaiveDateTime,
|
||||
|
||||
#[cfg(all(feature = "chrono", not(feature = "time")))]
|
||||
sqlx::types::chrono::DateTime<sqlx::types::chrono::Utc> | sqlx::types::chrono::DateTime<_>,
|
||||
|
||||
#[cfg(feature = "time")]
|
||||
sqlx::types::time::OffsetDateTime,
|
||||
|
||||
#[cfg(feature = "time")]
|
||||
sqlx::types::time::PrimitiveDateTime,
|
||||
|
||||
#[cfg(feature = "time")]
|
||||
sqlx::types::time::Date,
|
||||
|
||||
#[cfg(feature = "uuid")]
|
||||
sqlx::types::Uuid,
|
||||
},
|
||||
ParamChecking::Weak,
|
||||
// While there are type integrations that must be enabled via Cargo feature,
|
||||
// SQLite's type system doesn't actually have any type that we cannot decode by default.
|
||||
//
|
||||
// The type integrations simply allow the user to skip some intermediate representation,
|
||||
// which is usually TEXT.
|
||||
feature-types: _info => None,
|
||||
);
|
||||
Reference in New Issue
Block a user