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.
This commit is contained in:
Nicolas Stinus 2023-05-01 18:05:40 -04:00 committed by GitHub
parent 4f1ac1d606
commit dc9e298bff
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -145,6 +145,10 @@ fn decode_offset_datetime_from_text(value: &str) -> Option<OffsetDateTime> {
return Some(dt);
}
if let Some(dt) = decode_datetime_from_text(value) {
return Some(dt.assume_utc());
}
None
}