diff --git a/sqlx-postgres/src/types/time/time.rs b/sqlx-postgres/src/types/time/time.rs index fcd40145..7a9b99d9 100644 --- a/sqlx-postgres/src/types/time/time.rs +++ b/sqlx-postgres/src/types/time/time.rs @@ -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]]]"), )?, }) } diff --git a/tests/postgres/types.rs b/tests/postgres/types.rs index 2b2de07f..dbb40929 100644 --- a/tests/postgres/types.rs +++ b/tests/postgres/types.rs @@ -321,7 +321,8 @@ mod time_tests { test_type!(time_time