{"record":{"id":"3ea1cf3bfa332e83","repo":"diesel-rs/diesel","slug":"maximal-supported-month-interval-size-is-32-bit","errorCode":null,"errorMessage":"Maximal supported month interval size is 32 bit","messagePattern":"Maximal supported month interval size is 32 bit","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"diesel/src/pg/expression/extensions/interval_dsl.rs","lineNumber":229,"sourceCode":"    fn hours(self) -> PgInterval {\n        i64::from(self).hours()\n    }\n}\n\nimpl IntervalDsl for i64 {\n    fn microseconds(self) -> PgInterval {\n        PgInterval::from_microseconds(self)\n    }\n\n    fn days(self) -> PgInterval {\n        i32::try_from(self)\n            .expect(\"Maximal supported day interval size is 32 bit\")\n            .days()\n    }\n\n    fn months(self) -> PgInterval {\n        i32::try_from(self)\n            .expect(\"Maximal supported month interval size is 32 bit\")\n            .months()\n    }\n}\n\n#[allow(clippy::cast_possible_truncation)] // we want to truncate\nimpl IntervalDsl for f64 {\n    fn microseconds(self) -> PgInterval {\n        (self.round() as i64).microseconds()\n    }\n\n    fn days(self) -> PgInterval {\n        let fractional_days = (self.fract() * 86_400.0).seconds();\n        PgInterval::from_days(self.trunc() as i32) + fractional_days\n    }\n\n    fn months(self) -> PgInterval {\n        let fractional_months = (self.fract() * 30.0).days();\n        PgInterval::from_months(self.trunc() as i32) + fractional_months","sourceCodeStart":211,"sourceCodeEnd":247,"githubUrl":"https://github.com/diesel-rs/diesel/blob/6fa6ed01b24b24248ab2a611698d0a7c6a2e9120/diesel/src/pg/expression/extensions/interval_dsl.rs#L211-L247","documentation":"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).","triggerScenarios":"Thrown at diesel/src/pg/expression/extensions/interval_dsl.rs:229 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Keep the month count within i32 bounds","Split very large intervals into smaller units","Validate the input before calling `.months()`"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"6fa6ed01b24b24248ab2a611698d0a7c6a2e9120","analyzedAt":"2026-09-07T01:50:13.074Z","contentChangedAt":"2026-09-07T01:50:13.074Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}