{"record":{"id":"d7609c60dc74a47b","repo":"SeaQL/sea-orm","slug":"failed-to-get-date-d7609c","errorCode":null,"errorMessage":"Failed to get date","messagePattern":"Failed to get date","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/driver/sqlx_postgres.rs","lineNumber":759,"sourceCode":"                            feature = \"postgres-array\"\n                        ))]\n                        \"TIMESTAMP[]\" => Value::Array(\n                            sea_query::ArrayType::TimeDateTime,\n                            row.try_get::<Option<Vec<time::PrimitiveDateTime>>, _>(c.ordinal())\n                                .expect(\"Failed to get timestamp array\")\n                                .map(|vals| {\n                                    Box::new(\n                                        vals.into_iter()\n                                            .map(|val| Value::TimeDateTime(Some(val)))\n                                            .collect(),\n                                    )\n                                }),\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                        ),\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                        ),\n\n                        #[cfg(all(feature = \"with-chrono\", feature = \"postgres-array\"))]\n                        \"DATE[]\" => Value::Array(\n                            sea_query::ArrayType::ChronoDate,\n                            row.try_get::<Option<Vec<chrono::NaiveDate>>, _>(c.ordinal())\n                                .expect(\"Failed to get date array\")\n                                .map(|vals| {\n                                    Box::new(\n                                        vals.into_iter()\n                                            .map(|val| Value::ChronoDate(Some(val)))\n                                            .collect(),\n                                    )","sourceCodeStart":741,"sourceCodeEnd":777,"githubUrl":"https://github.com/SeaQL/sea-orm/blob/e29bcd1b417c41a553b386fe94511d7c64a1c8ec/src/driver/sqlx_postgres.rs#L741-L777","documentation":"Panic raised by `.expect()` in SeaORM's Postgres ProxyRow conversion: a column whose type string is `DATE` is decoded with sqlx as `Option<chrono::NaiveDate>` (chrono branch) or `Option<time::Date>` (time branch). If sqlx's decode returns an error — usually because the underlying Postgres type OID is not `date` — the panic message is \"Failed to get date\". It indicates the column metadata string and the actual wire type disagree.","triggerScenarios":"Selecting a DATE column through ProxyRow where the value cannot decode to `NaiveDate`/`time::Date` — e.g. the column is actually `timestamptz`, `timestamp`, or a custom domain over date, or the chrono/time feature required for the decode impl is not enabled as compiled.","commonSituations":"Views or CTEs that return date-valued expressions with inferred non-date types; DB schema changed a column from DATE to TIMESTAMP; mixing feature flags so neither `with-chrono` nor `with-time` decode impls line up with the branch chosen by the type string.","solutions":["Inspect the column's real type and make it exactly `date` (or cast: `SELECT d::date FROM ...`).","Enable `with-chrono` (or `with-time`) on sea-orm so the matching decode impl is compiled.","Update sea-orm/sqlx to a compatible pair where the date decode is supported for your Postgres version.","If the value may be NULL or non-date, avoid the proxy path or select as text and parse manually."],"exampleFix":"// before: col is actually timestamptz, decode to NaiveDate panics\nlet rows = stmt.map(|row| row.into_proxy_row()).await?;\n\n// after: force the date type in SQL\nlet stmt = Statement::from_string(\n    db.get_database_backend(),\n    \"SELECT birthday::date AS birthday FROM users\",\n);","handlingStrategy":"validation","validationCode":"let ty: Option<String> = sqlx::query_scalar(\n    \"SELECT data_type FROM information_schema.columns WHERE table_name=$1 AND column_name=$2\")\n    .bind(\"users\").bind(\"birthday\").fetch_optional(db).await?;\nassert_eq!(ty.as_deref(), Some(\"date\"));","typeGuard":"fn is_pg_date(data_type: &str) -> bool { data_type.eq_ignore_ascii_case(\"date\") }","tryCatchPattern":"// expect() panics; prefer validating first. If unavoidable:\nlet decoded = std::panic::catch_unwind(AssertUnwindSafe(|| row.into_proxy_row()));\nif decoded.is_err() { eprintln!(\"DATE column type mismatch — check schema\"); }","preventionTips":["Never select timestamp/timestamptz expressions into columns expected as DATE; cast with ::date.","Check views/CTEs for inferred non-date types on date-valued expressions.","Enable with-chrono or with-time explicitly in Cargo.toml features.","Guard schema changes with migration tests that exercise ProxyRow decoding."],"tags":["postgres","sqlx","type-mismatch","date"],"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"}