SeaQL/sea-orm · error
Failed to get time array
Error message
Failed to get time array
What it means
Panic from `.expect()` in SeaORM's Postgres ProxyRow conversion for `TIME[]` columns in the chrono branch. The driver decodes the column as `Option<Vec<chrono::NaiveTime>>`; when sqlx's decode fails (element type isn't `time`, or chrono array impl not compiled), the panic message is "Failed to get time array".
Source
Thrown at src/driver/sqlx_postgres.rs:813
}),
),
#[cfg(feature = "with-chrono")]
"TIME" => Value::ChronoTime(
row.try_get::<Option<chrono::NaiveTime>, _>(c.ordinal())
.expect("Failed to get time"),
),
#[cfg(all(feature = "with-time", not(feature = "with-chrono")))]
"TIME" => Value::TimeTime(
row.try_get::<Option<time::Time>, _>(c.ordinal())
.expect("Failed to get time"),
),
#[cfg(all(feature = "with-chrono", feature = "postgres-array"))]
"TIME[]" => Value::Array(
sea_query::ArrayType::ChronoTime,
row.try_get::<Option<Vec<chrono::NaiveTime>>, _>(c.ordinal())
.expect("Failed to get time array")
.map(|vals| {
Box::new(
vals.into_iter()
.map(|val| Value::ChronoTime(Some(val)))
.collect(),
)
}),
),
#[cfg(all(
feature = "with-time",
not(feature = "with-chrono"),
feature = "postgres-array"
))]
"TIME[]" => Value::Array(
sea_query::ArrayType::TimeTime,
row.try_get::<Option<Vec<time::Time>>, _>(c.ordinal())
.expect("Failed to get time array")
.map(|vals| {View on GitHub (pinned to e29bcd1b41)
Solutions
- Verify the column is exactly `time[]` and cast if needed (`col::time[]`).
- Enable `with-chrono` and `postgres-array` features together on sea-orm.
- Keep sea-orm and sqlx versions aligned for chrono array decoding.
- Select the array as text and parse elements when the source type is uncontrolled.
Example fix
// before: column is timetz[]
let rows = q.map(|row| row.into_proxy_row()).await?; // panics
// after
let stmt = Statement::from_string(
db.get_database_backend(),
"SELECT slots::time[] AS slots FROM calendars",
); 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("calendars").bind("slots").fetch_optional(db).await?;
assert_eq!(elem.as_deref(), Some("time without time zone")); Type guard
fn is_time_array(elem: &str) -> bool { elem.eq_ignore_ascii_case("time without time zone") } Try / catch
let result = std::panic::catch_unwind(AssertUnwindSafe(|| stmt_to_proxy_rows(&stmt)));
match result {
Ok(rows) => rows,
Err(_) => decode_time_array_as_text("slots"),
} Prevention
- Cast arrays to time[] in queries; never let timetz[] reach ProxyRow.
- Enable with-chrono + postgres-array features together.
- Inspect information_schema.element_types for true array element OIDs.
- Keep sea-orm/sqlx versions aligned; test array decoding in CI.
When it happens
Trigger: Selecting a `TIME[]` column through ProxyRow with `with-chrono` + `postgres-array` enabled and the value won't decode to `Vec<NaiveTime>` — e.g. the column is `timetz[]`, `timestamp[]`, or another array type misreported as `TIME[]`.
Common situations: Arrays of `TIME WITH TIME ZONE` elements; schema drift from time[] to interval[]; views with inferred array element types; missing `postgres-array` feature causing branch mis-selection; sea-orm/sqlx version skew.
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 array
- Failed to get time
- 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/9d178b2519508aed.
Report an issue: GitHub.