SeaQL/sea-orm · error
Failed to get date array
Error message
Failed to get date array
What it means
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".
Source
Thrown at src/driver/sqlx_postgres.rs:771
}),
),
#[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
- 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.
Example fix
// before: column is timestamptz[]
let rows = q.map(|row| row.into_proxy_row()).await?; // panics
// after
let stmt = Statement::from_string(
db.get_database_backend(),
"SELECT holidays::date[] AS holidays FROM schedules",
); Defensive patterns
Strategy: try-catch
Validate before calling
let elem: Option<String> = sqlx::query_scalar(
"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")
.bind("schedules").bind("holidays").fetch_optional(db).await?;
assert_eq!(elem.as_deref(), Some("date")); Type guard
fn is_date_array(elem_type: &str) -> bool { elem_type.eq_ignore_ascii_case("date") } Try / catch
let result = std::panic::catch_unwind(AssertUnwindSafe(|| stmt_to_proxy_rows(&stmt)));
match result {
Ok(rows) => rows,
Err(_) => decode_array_via_text_fallback("holidays"),
} Prevention
- 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.
When it happens
Trigger: 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[]`.
Common situations: 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.
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 timestamp array
- Failed to get date
- Failed to get time array
- Failed to get boolean array
- Failed to get small integer array
AI-assisted analysis of SeaQL/sea-orm@e29bcd1b41 (2026-09-10).
Data as JSON: /api/errors/6afe7c0a3691e151.
Report an issue: GitHub.