diff --git a/tests/postgres-types.rs b/tests/postgres-types.rs index 83f1370fcb..a4279ba328 100644 --- a/tests/postgres-types.rs +++ b/tests/postgres-types.rs @@ -346,6 +346,40 @@ mod time_tests { )); } +mod interval { + use super::*; + use sqlx::postgres::types::PgInterval; + + test_prepared_type!(interval( + Postgres, + PgInterval, + "INTERVAL '1h'" + == PgInterval { + months: 0, + days: 0, + microseconds: 3_600_000_000 + }, + "INTERVAL '-1 hours'" + == PgInterval { + months: 0, + days: 0, + microseconds: -3_600_000_000 + }, + "INTERVAL '3 months 12 days 1h 15 minutes 10 second '" + == PgInterval { + months: 3, + days: 12, + microseconds: (3_600 + 15 * 60 + 10) * 1_000_000 + }, + "INTERVAL '03:10:20.116100'" + == PgInterval { + months: 0, + days: 0, + microseconds: (3 * 3_600 + 10 * 60 + 20) * 1_000_000 + 116100 + }, + )); +} + // This is trying to break my complete lack of understanding of null bitmaps for array/record // decoding. The docs in pg are either wrong or I'm reading the wrong docs. test_type!(lots_of_nulls_vec(Postgres, Vec>,