{"record":{"id":"87591933c62ae758","repo":"SeaQL/sea-orm","slug":"failed-to-get-date-875919","errorCode":null,"errorMessage":"Failed to get date","messagePattern":"Failed to get date","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/driver/sqlx_mysql.rs","lineNumber":467,"sourceCode":"                        }\n\n                        #[cfg(feature = \"with-chrono\")]\n                        \"TIMESTAMP\" => Value::ChronoDateTimeUtc(\n                            row.try_get::<Option<chrono::DateTime<chrono::Utc>>, _>(c.ordinal())\n                                .expect(\"Failed to get timestamp\")\n                                .map(Box::new),\n                        ),\n                        #[cfg(all(feature = \"with-time\", not(feature = \"with-chrono\")))]\n                        \"TIMESTAMP\" => Value::TimeDateTime(\n                            row.try_get::<Option<time::PrimitiveDateTime>, _>(c.ordinal())\n                                .expect(\"Failed to get timestamp\")\n                                .map(Box::new),\n                        ),\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())","sourceCodeStart":449,"sourceCodeEnd":485,"githubUrl":"https://github.com/SeaQL/sea-orm/blob/e29bcd1b417c41a553b386fe94511d7c64a1c8ec/src/driver/sqlx_mysql.rs#L449-L485","documentation":"ProxyRow panicked while converting a MySQL DATE column under the `with-chrono` feature: `row.try_get::<Option<chrono::NaiveDate>, _>(c.ordinal())` failed and `.expect(\"Failed to get date\")` aborted. sqlx could not decode the raw value as chrono::NaiveDate, meaning the value does not match the declared DATE type.","triggerScenarios":"Fetching a DATE column whose value is the MySQL zero date '0000-00-00', an out-of-chrono-range date (year 0 or > ~year 262000), or a DATE-valued expression/string that sqlx refuses to coerce to NaiveDate.","commonSituations":"Databases imported from non-strict legacy systems containing '0000-00-00'; dates outside chrono's supported range; columns typed DATE in metadata but actually returned as VARCHAR by a view or UNION.","solutions":["Clean up zero/invalid dates: UPDATE t SET d = NULL WHERE d = '0000-00-00' and enable strict mode so MySQL rejects them going forward.","Cast suspect expressions to DATE in SQL (CAST(x AS DATE)) so the wire value matches the declared type.","Verify the column's declared type in information_schema matches what the query returns (views/UNIONs can change the effective type).","If you need dates beyond chrono's range, change the column to store YEAR/INT or select as string and parse manually.","Upgrade sea-orm/sqlx together if the failure started after a dependency bump — decode strictness changed across versions."],"exampleFix":"// before\nSELECT birth_date FROM users  -- row with '0000-00-00' panics\n\n// after\nSELECT NULLIF(birth_date, '0000-00-00') AS birth_date FROM users","handlingStrategy":"validation","validationCode":"// Pre-flight: count undecodable DATE values\n// SELECT COUNT(*) FROM users WHERE birth_date = '0000-00-00'\nlet n = fetch_count(db, \"users\", \"birth_date = '0000-00-00'\").await?;\nif n > 0 { eprintln!(\"fix {} zero dates before querying\", n); }","typeGuard":"fn valid_mysql_date(s: &str) -> bool {\n    s != \"0000-00-00\" && chrono::NaiveDate::parse_from_str(s, \"%Y-%m-%d\").is_ok()\n}","tryCatchPattern":"let decoded = std::panic::catch_unwind(|| proxy_row.decode_date(ordinal)).ok();\nlet date = decoded.flatten().or_else(|| fallback_parse_date_as_string(ordinal));","preventionTips":["Run MySQL with strict mode; forbid zero dates","NULLIF zero dates in raw SELECTs against legacy tables","CAST expression results to DATE so declared and runtime types match","Check views/UNION branches for effective-type drift","Keep dates within chrono's representable range or change the column type"],"tags":["mysql","sqlx","date","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"}