{"record":{"id":"6afe7c0a3691e151","repo":"SeaQL/sea-orm","slug":"failed-to-get-date-array-6afe7c","errorCode":null,"errorMessage":"Failed to get date array","messagePattern":"Failed to get date array","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/driver/sqlx_postgres.rs","lineNumber":771,"sourceCode":"                                }),\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                                    )\n                                }),\n                        ),\n                        #[cfg(all(\n                            feature = \"with-time\",\n                            not(feature = \"with-chrono\"),\n                            feature = \"postgres-array\"\n                        ))]\n                        \"DATE[]\" => Value::Array(\n                            sea_query::ArrayType::TimeDate,\n                            row.try_get::<Option<Vec<time::Date>>, _>(c.ordinal())\n                                .expect(\"Failed to get date array\")\n                                .map(|vals| {","sourceCodeStart":753,"sourceCodeEnd":789,"githubUrl":"https://github.com/SeaQL/sea-orm/blob/e29bcd1b417c41a553b386fe94511d7c64a1c8ec/src/driver/sqlx_postgres.rs#L753-L789","documentation":"Panic from `.expect()` in SeaORM's Postgres ProxyRow conversion for `DATE[]` columns in the chrono branch. The driver decodes the column as `Option<Vec<chrono::NaiveDate>>`; a sqlx decode failure (the column's element OID isn't `date`, or the chrono array impl isn't compiled) becomes the panic \"Failed to get date array\".","triggerScenarios":"Selecting a `DATE[]` column through ProxyRow with `with-chrono` + `postgres-array` features, and the value doesn't decode to `Vec<NaiveDate>` — typically because the column is `timestamptz[]`, `timestamp[]`, a domain, or an int-array mistakenly matched as `DATE[]`.","commonSituations":"Schema drift where the array element type changed; using generated columns or views with unexpected array element types; feature flags missing `postgres-array` so a prior branch grabbed the value; sqlx/sea-orm version mismatch removing chrono array decode support.","solutions":["Confirm the column type is exactly `date[]` (`\\d table`) and cast in SQL if it isn't (`col::date[]`).","Enable both `with-chrono` and `postgres-array` features on sea-orm.","Align sea-orm and sqlx versions so chrono array decoding is available.","Select the array as JSON/text and parse manually when the element type is uncertain."],"exampleFix":"// before: column is timestamptz[]\nlet rows = q.map(|row| row.into_proxy_row()).await?; // panics\n\n// after\nlet stmt = Statement::from_string(\n    db.get_database_backend(),\n    \"SELECT holidays::date[] AS holidays FROM schedules\",\n);","handlingStrategy":"try-catch","validationCode":"let elem: Option<String> = sqlx::query_scalar(\n    \"SELECT e.data_type FROM information_schema.columns c, LATERAL (SELECT data_type FROM information_schema.element_types WHERE object_name=c.table_name AND collection_type_identifier=c.dtd_identifier) e WHERE c.table_name=$1 AND c.column_name=$2\")\n    .bind(\"schedules\").bind(\"holidays\").fetch_optional(db).await?;\nassert_eq!(elem.as_deref(), Some(\"date\"));","typeGuard":"fn is_date_array(elem_type: &str) -> bool { elem_type.eq_ignore_ascii_case(\"date\") }","tryCatchPattern":"let result = std::panic::catch_unwind(AssertUnwindSafe(|| stmt_to_proxy_rows(&stmt)));\nmatch result {\n    Ok(rows) => rows,\n    Err(_) => decode_array_via_text_fallback(\"holidays\"),\n}","preventionTips":["Cast arrays explicitly: holidays::date[] in queries reaching ProxyRow.","Verify both with-chrono and postgres-array features are enabled.","Detect array element types via information_schema.element_types, not column data_type.","Cover array columns with decode integration tests."],"tags":["postgres","sqlx","type-mismatch","array-decode","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"}