From afb87647fe51222df3e0817a08d958a61b1763bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Carr?= Date: Sun, 19 Apr 2020 19:07:00 -0700 Subject: [PATCH] postgres: Create postgres-types for PgInterval --- tests/postgres-types.rs | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) 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>,