SeaQL/sea-orm · error
Failed to get date array
Error message
Failed to get date array
What it means
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.
Source
Thrown at sea-orm-sync/src/driver/sqlx_postgres.rs:758
}),
),
#[cfg(feature = "with-chrono")]
"DATE" => Value::ChronoDate(
row.try_get::<Option<chrono::NaiveDate>, _>(c.ordinal())
.expect("Failed to get date"),
),
#[cfg(all(feature = "with-time", not(feature = "with-chrono")))]
"DATE" => Value::TimeDate(
row.try_get::<Option<time::Date>, _>(c.ordinal())
.expect("Failed to get date"),
),
#[cfg(all(feature = "with-chrono", feature = "postgres-array"))]
"DATE[]" => Value::Array(
sea_query::ArrayType::ChronoDate,
row.try_get::<Option<Vec<chrono::NaiveDate>>, _>(c.ordinal())
.expect("Failed to get date array")
.map(|vals| {
Box::new(
vals.into_iter()
.map(|val| Value::ChronoDate(Some(val)))
.collect(),
)
}),
),
#[cfg(all(
feature = "with-time",
not(feature = "with-chrono"),
feature = "postgres-array"
))]
"DATE[]" => Value::Array(
sea_query::ArrayType::TimeDate,
row.try_get::<Option<Vec<time::Date>>, _>(c.ordinal())
.expect("Failed to get date array")
.map(|vals| {View on GitHub (pinned to e29bcd1b41)
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.
Example fix
// before SELECT array_agg(day) FROM shifts; -- day is timestamp -> element type mismatch // after SELECT array_agg(day::date)::date[] AS days FROM shifts;
Defensive patterns
Strategy: validation
Validate before calling
SELECT e.data_type AS element_type FROM information_schema.element_types e WHERE e.table_name = $1 AND e.column_name = $2; -- element_type must be 'date' for Vec<NaiveDate>
Type guard
fn is_date_array(el: &str) -> bool { el == "date" } Try / catch
let vals = row.try_get::<Option<Vec<chrono::NaiveDate>>, _>(idx)
.map_err(|e| DecodeError::DateArray { column: idx, source: e })?; Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: Type mismatch errors: IllegalArgumentException, TypeError and type guards across 150 open-source libraries — this error's family across 150 libraries.
Related errors
- Failed to get boolean array
- Failed to get small integer array
- Failed to get integer array
- Failed to get big integer array
- Failed to get timestamp array
AI-assisted analysis of SeaQL/sea-orm@e29bcd1b41 (2026-09-10).
Data as JSON: /api/errors/2bd8ba7d64cf58d0.
Report an issue: GitHub.