From 5ed0d24df723b6b99b9816315897d13477c5eb8f Mon Sep 17 00:00:00 2001 From: Billy Chan Date: Tue, 28 Sep 2021 17:45:32 +0800 Subject: [PATCH 1/4] Fix SQLite encoding format --- sqlx-core/src/sqlite/types/chrono.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sqlx-core/src/sqlite/types/chrono.rs b/sqlx-core/src/sqlite/types/chrono.rs index cd01c3bde2..23fd3e18f6 100644 --- a/sqlx-core/src/sqlite/types/chrono.rs +++ b/sqlx-core/src/sqlite/types/chrono.rs @@ -76,7 +76,7 @@ impl Encode<'_, Sqlite> for NaiveDate { impl Encode<'_, Sqlite> for NaiveTime { fn encode_by_ref(&self, buf: &mut Vec>) -> IsNull { - Encode::::encode(self.format("%T%.f%").to_string(), buf) + Encode::::encode(self.format("%T%.f").to_string(), buf) } } From 2e639483d236ce44dab60e5f6e9174b59c99389b Mon Sep 17 00:00:00 2001 From: Billy Chan Date: Tue, 28 Sep 2021 17:47:28 +0800 Subject: [PATCH 2/4] Update SQLite decoding format --- sqlx-core/src/sqlite/types/chrono.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sqlx-core/src/sqlite/types/chrono.rs b/sqlx-core/src/sqlite/types/chrono.rs index 23fd3e18f6..1a9bdd214e 100644 --- a/sqlx-core/src/sqlite/types/chrono.rs +++ b/sqlx-core/src/sqlite/types/chrono.rs @@ -181,7 +181,8 @@ impl<'r> Decode<'r, Sqlite> for NaiveTime { // https://github.com/diesel-rs/diesel/blob/93ab183bcb06c69c0aee4a7557b6798fd52dd0d8/diesel/src/sqlite/types/date_and_time/chrono.rs#L29-L47 let sqlite_time_formats = &[ // Most likely format - "%T.f", // Other formats in order of appearance in docs + "%T.f", "%T%.f", + // Other formats in order of appearance in docs "%R", "%RZ", "%T%.fZ", "%R%:z", "%T%.f%:z", ]; From 9f95cbc38838c955cb661be60ce6e62479b745bf Mon Sep 17 00:00:00 2001 From: Austin Bonander Date: Thu, 30 Sep 2021 19:29:50 -0700 Subject: [PATCH 3/4] Update sqlx-core/src/sqlite/types/chrono.rs --- sqlx-core/src/sqlite/types/chrono.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/sqlx-core/src/sqlite/types/chrono.rs b/sqlx-core/src/sqlite/types/chrono.rs index 1a9bdd214e..49b3d40588 100644 --- a/sqlx-core/src/sqlite/types/chrono.rs +++ b/sqlx-core/src/sqlite/types/chrono.rs @@ -181,6 +181,7 @@ impl<'r> Decode<'r, Sqlite> for NaiveTime { // https://github.com/diesel-rs/diesel/blob/93ab183bcb06c69c0aee4a7557b6798fd52dd0d8/diesel/src/sqlite/types/date_and_time/chrono.rs#L29-L47 let sqlite_time_formats = &[ // Most likely format + #[rustfmt::skip] "%T.f", "%T%.f", // Other formats in order of appearance in docs "%R", "%RZ", "%T%.fZ", "%R%:z", "%T%.f%:z", From 3ccbf9c3498f870a03941fe089b487204a4edfd5 Mon Sep 17 00:00:00 2001 From: Austin Bonander Date: Thu, 30 Sep 2021 19:35:20 -0700 Subject: [PATCH 4/4] fixup: add `#[rustfmt::skip]` --- sqlx-core/src/sqlite/types/chrono.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sqlx-core/src/sqlite/types/chrono.rs b/sqlx-core/src/sqlite/types/chrono.rs index 49b3d40588..1ebb2c4f45 100644 --- a/sqlx-core/src/sqlite/types/chrono.rs +++ b/sqlx-core/src/sqlite/types/chrono.rs @@ -179,9 +179,9 @@ impl<'r> Decode<'r, Sqlite> for NaiveTime { // Loop over common time patterns, inspired by Diesel // https://github.com/diesel-rs/diesel/blob/93ab183bcb06c69c0aee4a7557b6798fd52dd0d8/diesel/src/sqlite/types/date_and_time/chrono.rs#L29-L47 + #[rustfmt::skip] // don't like how rustfmt mangles the comments let sqlite_time_formats = &[ // Most likely format - #[rustfmt::skip] "%T.f", "%T%.f", // Other formats in order of appearance in docs "%R", "%RZ", "%T%.fZ", "%R%:z", "%T%.f%:z",