{"record":{"id":"dd13a6feeb9892ff","repo":"SeaQL/sea-orm","slug":"failed-to-get-date","errorCode":null,"errorMessage":"Failed to get date","messagePattern":"Failed to get date","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sea-orm-sync/src/driver/sqlx_mysql.rs","lineNumber":459,"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":441,"sourceCodeEnd":477,"githubUrl":"https://github.com/SeaQL/sea-orm/blob/e29bcd1b417c41a553b386fe94511d7c64a1c8ec/sea-orm-sync/src/driver/sqlx_mysql.rs#L441-L477","documentation":"This panic comes from the `with-chrono` DATE branch of `ProxyRow` in the MySQL driver: `sqlx::Row::try_get::<Option<chrono::NaiveDate>, _>` failed for a \"DATE\" column at `c.ordinal()`. The `expect` turns the sqlx decode failure into a panic with \"Failed to get date\". It means the value cannot be decoded as a `chrono::NaiveDate`, typically because the column no longer holds DATE data or contains out-of-range/zero dates.","triggerScenarios":"Reading a MySQL DATE column while compiled with `with-chrono`, when the raw value is not decodable as `chrono::NaiveDate` — e.g. metadata says DATE but the column is now VARCHAR/DATETIME, or MySQL zero-date '0000-00-00' is present.","commonSituations":"Legacy MySQL data with zero-dates; schema drift after ALTER TABLE; using stale table metadata captured before a column type change.","solutions":["Refresh the table metadata so DATE mapping matches the live schema (`SHOW CREATE TABLE`).","Find and fix zero-dates ('0000-00-00') or out-of-range dates in the table; set sql_mode to reject them going forward.","Verify the column is genuinely DATE and not DATETIME/VARCHAR; adjust schema or query.","Patch the driver to return DbErr instead of `expect` so the real decode error is reported."],"exampleFix":"// before\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// after\n\"DATE\" => Value::ChronoDate(\n    row.try_get::<Option<chrono::NaiveDate>, _>(c.ordinal())\n        .map_err(|e| DbErr::TryGetErr(...))? // propagate instead of panicking\n        .map(Box::new),\n)","handlingStrategy":"validation","validationCode":"// Ensure DATE columns hold valid dates before querying\n// SELECT COUNT(*) FROM t WHERE d = '0000-00-00'; must be 0\nassert_eq!(col.type_name, \"DATE\");","typeGuard":null,"tryCatchPattern":"// The panic is raised by .expect in the driver; guard the call site:\nstd::panic::catch_unwind(|| proxy_row_from(&row, &columns))\n    .map_err(|_| DbErr::Custom(\"DATE column decode failed\".into()))?","preventionTips":["Enable NO_ZERO_DATE in MySQL sql_mode to prevent zero-dates at write time.","Refresh metadata after ALTER TABLE operations on DATE columns.","Keep `with-chrono` flags consistent throughout the build.","Audit legacy tables for '0000-00-00' values before migrating to this driver."],"tags":["mysql","sqlx","chrono","date","panic"],"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"}