Skip to content

Commit 8561891

Browse files
billy1624abonander
andauthored
[SQLite] encoding & decoding NaiveTime with correct format (#1459)
* Fix SQLite encoding format * Update SQLite decoding format * Update sqlx-core/src/sqlite/types/chrono.rs * fixup: add `#[rustfmt::skip]` Co-authored-by: Austin Bonander <[email protected]> Co-authored-by: Austin Bonander <[email protected]>
1 parent 51e45ce commit 8561891

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

sqlx-core/src/sqlite/types/chrono.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ impl Encode<'_, Sqlite> for NaiveDate {
7676

7777
impl Encode<'_, Sqlite> for NaiveTime {
7878
fn encode_by_ref(&self, buf: &mut Vec<SqliteArgumentValue<'_>>) -> IsNull {
79-
Encode::<Sqlite>::encode(self.format("%T%.f%").to_string(), buf)
79+
Encode::<Sqlite>::encode(self.format("%T%.f").to_string(), buf)
8080
}
8181
}
8282

@@ -179,9 +179,11 @@ impl<'r> Decode<'r, Sqlite> for NaiveTime {
179179

180180
// Loop over common time patterns, inspired by Diesel
181181
// https://github.com/diesel-rs/diesel/blob/93ab183bcb06c69c0aee4a7557b6798fd52dd0d8/diesel/src/sqlite/types/date_and_time/chrono.rs#L29-L47
182+
#[rustfmt::skip] // don't like how rustfmt mangles the comments
182183
let sqlite_time_formats = &[
183184
// Most likely format
184-
"%T.f", // Other formats in order of appearance in docs
185+
"%T.f", "%T%.f",
186+
// Other formats in order of appearance in docs
185187
"%R", "%RZ", "%T%.fZ", "%R%:z", "%T%.f%:z",
186188
];
187189

0 commit comments

Comments
 (0)