Skip to content

Commit

Permalink
postgres: Create postgres-types for PgInterval
Browse files Browse the repository at this point in the history
  • Loading branch information
dimtion committed Apr 20, 2020
1 parent 381beb4 commit afb8764
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions tests/postgres-types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Option<bool>>,
Expand Down

0 comments on commit afb8764

Please sign in to comment.