Skip to content

Commit

Permalink
Fix: remove redundancy because nanosecond overflow implies microsecon…
Browse files Browse the repository at this point in the history
…d overflow
  • Loading branch information
yuyawk committed Oct 30, 2021
1 parent 74b3950 commit 032092b
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions sqlx-core/src/postgres/types/interval.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ impl TryFrom<chrono::Duration> for PgInterval {
/// Convert a `chrono::Duration` to a `PgInterval`.
///
/// This returns an error if there is a loss of precision using nanoseconds or if there is a
/// microsecond or nanosecond overflow.
/// nanosecond overflow.
fn try_from(value: chrono::Duration) -> Result<Self, BoxDynError> {
value
.num_nanoseconds()
Expand Down Expand Up @@ -353,10 +353,6 @@ fn test_pginterval_chrono() {
assert!(PgInterval::try_from(chrono::Duration::nanoseconds(27_000_001)).is_err());
assert!(PgInterval::try_from(chrono::Duration::nanoseconds(-27_000_001)).is_err());

// Case when microsecond overflow occurs
assert!(PgInterval::try_from(chrono::Duration::seconds(10_000_000_000_000)).is_err());
assert!(PgInterval::try_from(chrono::Duration::seconds(-10_000_000_000_000)).is_err());

// Case when nanosecond overflow occurs
assert!(PgInterval::try_from(chrono::Duration::seconds(10_000_000_000)).is_err());
assert!(PgInterval::try_from(chrono::Duration::seconds(-10_000_000_000)).is_err());
Expand Down

0 comments on commit 032092b

Please sign in to comment.