diesel-rs/diesel · error
Maximal supported month interval size is 32 bit
Error message
Maximal supported month interval size is 32 bit
What it means
Runtime panic in IntervalDsl for i64 (PostgreSQL interval construction). PgInterval stores months and days as i32; when a 64-bit value like `1_000_000_000_000.days()` or `.months()` cannot fit into i32, i32::try_from fails and this expect panics instead of silently truncating. It fires at query-construction time, not at the database. Fix: use a value within the 32-bit range for days/months (microseconds keep full i64 range).
Solutions
- Keep the month count within i32 bounds
- Split very large intervals into smaller units
- Validate the input before calling `.months()`
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at diesel/src/pg/expression/extensions/interval_dsl.rs:229 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of diesel-rs/diesel@6fa6ed01b2 (2026-09-07).
Data as JSON: /api/errors/3ea1cf3bfa332e83.
Report an issue: GitHub.
Appendix: source
Thrown at diesel/src/pg/expression/extensions/interval_dsl.rs:229
fn hours(self) -> PgInterval {
i64::from(self).hours()
}
}
impl IntervalDsl for i64 {
fn microseconds(self) -> PgInterval {
PgInterval::from_microseconds(self)
}
fn days(self) -> PgInterval {
i32::try_from(self)
.expect("Maximal supported day interval size is 32 bit")
.days()
}
fn months(self) -> PgInterval {
i32::try_from(self)
.expect("Maximal supported month interval size is 32 bit")
.months()
}
}
#[allow(clippy::cast_possible_truncation)] // we want to truncate
impl IntervalDsl for f64 {
fn microseconds(self) -> PgInterval {
(self.round() as i64).microseconds()
}
fn days(self) -> PgInterval {
let fractional_days = (self.fract() * 86_400.0).seconds();
PgInterval::from_days(self.trunc() as i32) + fractional_days
}
fn months(self) -> PgInterval {
let fractional_months = (self.fract() * 30.0).days();
PgInterval::from_months(self.trunc() as i32) + fractional_monthsView on GitHub (pinned to 6fa6ed01b2)