{"record":{"id":"867f59a0afffe582","repo":"SeaQL/sea-orm","slug":"failed-to-get-time-867f59","errorCode":null,"errorMessage":"Failed to get time","messagePattern":"Failed to get time","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/driver/sqlx_mysql.rs","lineNumber":480,"sourceCode":"                        ),\n\n                        #[cfg(feature = \"with-chrono\")]\n                        \"DATE\" => Value::ChronoDate(\n                            row.try_get::<Option<chrono::NaiveDate>, _>(c.ordinal())\n                                .expect(\"Failed to get date\")\n                                .map(Box::new),\n                        ),\n                        #[cfg(all(feature = \"with-time\", not(feature = \"with-chrono\")))]\n                        \"DATE\" => Value::TimeDate(\n                            row.try_get::<Option<time::Date>, _>(c.ordinal())\n                                .expect(\"Failed to get date\")\n                                .map(Box::new),\n                        ),\n\n                        #[cfg(feature = \"with-chrono\")]\n                        \"TIME\" => Value::ChronoTime(\n                            row.try_get::<Option<chrono::NaiveTime>, _>(c.ordinal())\n                                .expect(\"Failed to get time\")\n                                .map(Box::new),\n                        ),\n                        #[cfg(all(feature = \"with-time\", not(feature = \"with-chrono\")))]\n                        \"TIME\" => Value::TimeTime(\n                            row.try_get::<Option<time::Time>, _>(c.ordinal())\n                                .expect(\"Failed to get time\")\n                                .map(Box::new),\n                        ),\n\n                        #[cfg(feature = \"with-chrono\")]\n                        \"DATETIME\" => Value::ChronoDateTime(\n                            row.try_get::<Option<chrono::NaiveDateTime>, _>(c.ordinal())\n                                .expect(\"Failed to get datetime\")\n                                .map(Box::new),\n                        ),\n                        #[cfg(all(feature = \"with-time\", not(feature = \"with-chrono\")))]\n                        \"DATETIME\" => Value::TimeDateTime(\n                            row.try_get::<Option<time::PrimitiveDateTime>, _>(c.ordinal())","sourceCodeStart":462,"sourceCodeEnd":498,"githubUrl":"https://github.com/SeaQL/sea-orm/blob/e29bcd1b417c41a553b386fe94511d7c64a1c8ec/src/driver/sqlx_mysql.rs#L462-L498","documentation":"ProxyRow panicked while converting a MySQL TIME column under `with-chrono`: `row.try_get::<Option<chrono::NaiveTime>, _>(c.ordinal())` returned Err and `.expect(\"Failed to get time\")` panicked. sqlx could not decode the value as chrono::NaiveTime, i.e. the wire value does not conform to the declared TIME type.","triggerScenarios":"Reading a TIME column holding an out-of-range value (MySQL TIME supports up to 838:59:59, far beyond NaiveTime's 24h), negative durations, or an expression that returns a string/packed value instead of a decodable TIME.","commonSituations":"Columns used to store durations or intervals rather than times of day — the top cause, since MySQL TIME legitimately holds values chrono::NaiveTime cannot represent; TIMEDIFF() results; legacy data with negative times.","solutions":["If the column stores durations, don't decode it as TIME: select it as a string/seconds number (TIME_TO_SEC(col)) and convert in Rust, or change the column to BIGINT seconds.","Clamp or validate values in SQL: SELECT LEAST(col, '23:59:59') when you know values should be times of day.","Enable strict mode and add CHECK constraints so invalid time-of-day values cannot be inserted.","Verify the effective type of expressions (TIMEDIFF, ADDTIME) and cast appropriately before fetching.","Upgrade sqlx/sea-orm in lockstep if decode behavior changed after a dependency update."],"exampleFix":"// before — duration column exceeds NaiveTime range, panics\nSELECT elapsed_time FROM jobs\n\n// after — fetch as seconds instead of TIME\nSELECT TIME_TO_SEC(elapsed_time) AS elapsed_seconds FROM jobs","handlingStrategy":"validation","validationCode":"// TIME columns used for durations exceed NaiveTime range; verify first\n// SELECT COUNT(*) FROM jobs WHERE elapsed_time > '23:59:59'\nif count_over_24h(db, \"jobs\", \"elapsed_time\").await? > 0 {\n    bail!(\"column stores durations; decode as TIME_TO_SEC instead\");\n}","typeGuard":"fn is_time_of_day(s: &str) -> bool {\n    chrono::NaiveTime::parse_from_str(s, \"%H:%M:%S\").is_ok()\n}","tryCatchPattern":"let time_val = std::panic::catch_unwind(|| row.try_decode_time(ordinal)).ok();\nmatch time_val {\n    Some(v) => v,\n    None => fetch_as_seconds(ordinal).await, // TIME_TO_SEC fallback\n}","preventionTips":["Never use TIME columns for durations > 24h — use BIGINT seconds or DECIMAL intervals","Add CHECK (col BETWEEN '00:00:00' AND '23:59:59') constraints for time-of-day semantics","Convert TIMEDIFF/ADDTIME results in SQL before fetching","Validate stored formats when migrating between servers","Watch for sqlx decode-rule changes on upgrades"],"tags":["mysql","sqlx","time","chrono","panic","decode"],"backgroundTag":"type-mismatch","analyzedSha":"e29bcd1b417c41a553b386fe94511d7c64a1c8ec","analyzedAt":"2026-09-10T11:31:52.468Z","contentChangedAt":"2026-09-10T11:31:52.468Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}