mirror of
https://github.com/launchbadge/sqlx
synced 2024-11-10 14:34:19 +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(
|
||||
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>(
|
||||
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>(
|
||||
|
|
Loading…
Reference in a new issue