Skip to content

Commit dc9e298

Browse files
authored
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.
1 parent 4f1ac1d commit dc9e298

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

sqlx-sqlite/src/types/time.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,10 @@ fn decode_offset_datetime_from_text(value: &str) -> Option<OffsetDateTime> {
145145
return Some(dt);
146146
}
147147

148+
if let Some(dt) = decode_datetime_from_text(value) {
149+
return Some(dt.assume_utc());
150+
}
151+
148152
None
149153
}
150154

0 commit comments

Comments
 (0)