mirror of
https://github.com/launchbadge/sqlx
synced 2024-09-20 14:21:57 +00:00
fix: decode postgres time without subsecond (#2784)
* fix: decode postgres time without subsecond * update: decode postgres time without subsecond by making subsecond optional
This commit is contained in:
parent
4bac21da37
commit
846dcfe52a
2 changed files with 4 additions and 2 deletions
|
@ -42,7 +42,8 @@ impl<'r> Decode<'r, Postgres> for Time {
|
||||||
|
|
||||||
PgValueFormat::Text => Time::parse(
|
PgValueFormat::Text => Time::parse(
|
||||||
value.as_str()?,
|
value.as_str()?,
|
||||||
&format_description!("[hour]:[minute]:[second].[subsecond]"),
|
// Postgres will not include the subsecond part if it's zero.
|
||||||
|
&format_description!("[hour]:[minute]:[second][optional [.[subsecond]]]"),
|
||||||
)?,
|
)?,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -321,7 +321,8 @@ mod time_tests {
|
||||||
|
|
||||||
test_type!(time_time<Time>(
|
test_type!(time_time<Time>(
|
||||||
Postgres,
|
Postgres,
|
||||||
"TIME '05:10:20.115100'" == time!(5:10:20.115100)
|
"TIME '05:10:20.115100'" == time!(5:10:20.115100),
|
||||||
|
"TIME '05:10:20'" == time!(5:10:20)
|
||||||
));
|
));
|
||||||
|
|
||||||
test_type!(time_date_time<PrimitiveDateTime>(
|
test_type!(time_date_time<PrimitiveDateTime>(
|
||||||
|
|
Loading…
Reference in a new issue