From dc9e298bff97cd40b3e4e912b9309fc88c14bd2d Mon Sep 17 00:00:00 2001 From: Nicolas Stinus Date: Mon, 1 May 2023 18:05:40 -0400 Subject: [PATCH] fix(sqlx-core): allow time::OffsetDateTime to be built from sqlite's CURRENT_TIMESTAMP (#2285) SQLite's CURRENT_TIMESTAMP keyword fills a DATETIME column as a UTC expressed string in the following format: "YYYY-MM-DD HH:MM:SS". Unfortunately, this format lacks the timezone information to safely build a time::OffsetDateTime. If all else fails, this patch will try to build it by assuming the missing timezine is UTC. --- sqlx-sqlite/src/types/time.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sqlx-sqlite/src/types/time.rs b/sqlx-sqlite/src/types/time.rs index de8f3608..b25d7c72 100644 --- a/sqlx-sqlite/src/types/time.rs +++ b/sqlx-sqlite/src/types/time.rs @@ -145,6 +145,10 @@ fn decode_offset_datetime_from_text(value: &str) -> Option { return Some(dt); } + if let Some(dt) = decode_datetime_from_text(value) { + return Some(dt.assume_utc()); + } + None }