diff --git a/sqlx-core/src/sqlite/type_info.rs b/sqlx-core/src/sqlite/type_info.rs index 83ba25f3..5af2b38e 100644 --- a/sqlx-core/src/sqlite/type_info.rs +++ b/sqlx-core/src/sqlite/type_info.rs @@ -22,7 +22,7 @@ pub(crate) enum DataType { // non-standard extensions Bool, Int64, - Timestamp, + Datetime, } /// Type information for a SQLite type. @@ -48,7 +48,7 @@ impl TypeInfo for SqliteTypeInfo { // non-standard extensions DataType::Bool => "BOOLEAN", DataType::Int64 => "BIGINT", - DataType::Timestamp => "TIMESTAMP", + DataType::Datetime => "DATETIME", } } } @@ -78,6 +78,7 @@ impl FromStr for DataType { Ok(match &*s { "int8" => DataType::Int64, "boolean" | "bool" => DataType::Bool, + "datetime" | "timestamp" => DataType::Datetime, _ if s.contains("int") && s.contains("big") && s.find("int") > s.find("big") => { DataType::Int64 @@ -123,7 +124,7 @@ fn test_data_type_from_str() -> Result<(), BoxDynError> { assert_eq!(DataType::Bool, "BOOLEAN".parse()?); assert_eq!(DataType::Bool, "BOOL".parse()?); - assert_eq!(DataType::Timestamp, "TIMESTAMP".parse()?); + assert_eq!(DataType::Datetime, "DATETIME".parse()?); Ok(()) } diff --git a/sqlx-core/src/sqlite/types/chrono.rs b/sqlx-core/src/sqlite/types/chrono.rs index f6e9b090..7abf06ba 100644 --- a/sqlx-core/src/sqlite/types/chrono.rs +++ b/sqlx-core/src/sqlite/types/chrono.rs @@ -9,7 +9,7 @@ use chrono::prelude::*; impl Type for NaiveDateTime { fn type_info() -> SqliteTypeInfo { - SqliteTypeInfo(DataType::Timestamp) + SqliteTypeInfo(DataType::Datetime) } } @@ -57,7 +57,7 @@ fn decode_naive_from_text(text: &str) -> Result { impl Type for DateTime { fn type_info() -> SqliteTypeInfo { - SqliteTypeInfo(DataType::Timestamp) + SqliteTypeInfo(DataType::Datetime) } } diff --git a/sqlx-core/src/sqlite/types/mod.rs b/sqlx-core/src/sqlite/types/mod.rs index c9eccbf1..9553d5a2 100644 --- a/sqlx-core/src/sqlite/types/mod.rs +++ b/sqlx-core/src/sqlite/types/mod.rs @@ -19,7 +19,9 @@ //! //! | Rust type | Sqlite type(s) | //! |---------------------------------------|------------------------------------------------------| -//! | `chrono::NaiveDateTime` | TIMESTAMP | +//! | `chrono::NaiveDateTime` | DATETIME | +//! | `chrono::DateTime` | DATETIME | +//! | `chrono::DateTime` | DATETIME | //! //! # Nullable //!