{"record":{"id":"2bd8ba7d64cf58d0","repo":"SeaQL/sea-orm","slug":"failed-to-get-date-array","errorCode":null,"errorMessage":"Failed to get date array","messagePattern":"Failed to get date array","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sea-orm-sync/src/driver/sqlx_postgres.rs","lineNumber":758,"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":740,"sourceCodeEnd":776,"githubUrl":"https://github.com/SeaQL/sea-orm/blob/e29bcd1b417c41a553b386fe94511d7c64a1c8ec/sea-orm-sync/src/driver/sqlx_postgres.rs#L740-L776","documentation":"This panic fires when decoding a Postgres DATE[] array column into Vec<chrono::NaiveDate> (with-chrono + postgres-array). The .expect(\"Failed to get date array\") turns sqlx's array type/decode mismatch into a panic. Array decodes are stricter: both the array-ness and the element type OID must match the requested Rust element type.","triggerScenarios":"Selecting a \"DATE[]\" column that is actually date[] with NULLs handled differently than expected, or a timestamptz[]/custom array whose name matched \"DATE[]\", or half-enabled postgres-array features.","commonSituations":"array_agg over timestamp columns producing timestamptz[]; schema drift changing array element types; server upgrades changing type OIDs; trying to decode scalar date values through the array arm.","solutions":["Cast the expression: `SELECT col::date[]` (or `array_agg(x::date)::date[]`) to pin the element type.","Verify the array element type in information_schema.element_types and fix schema drift.","Enable `postgres-array` consistently on sea-orm-sync and sqlx with a matching chrono version.","Coalesce/filter NULL elements in SQL if the decoder rejects them."],"exampleFix":"// before\nSELECT array_agg(day) FROM shifts; -- day is timestamp -> element type mismatch\n// after\nSELECT array_agg(day::date)::date[] AS days FROM shifts;","handlingStrategy":"validation","validationCode":"SELECT e.data_type AS element_type FROM information_schema.element_types e\nWHERE e.table_name = $1 AND e.column_name = $2;\n-- element_type must be 'date' for Vec<NaiveDate>","typeGuard":"fn is_date_array(el: &str) -> bool { el == \"date\" }","tryCatchPattern":"let vals = row.try_get::<Option<Vec<chrono::NaiveDate>>, _>(idx)\n    .map_err(|e| DecodeError::DateArray { column: idx, source: e })?;","preventionTips":["Cast aggregates: array_agg(x::date)::date[]","Inspect element_types for array columns, not just data_type","Enable postgres-array features uniformly across dependencies","Handle NULLs in SQL before array decode"],"tags":["postgres","sqlx","array-decode","date-array","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"}