SeaQL/sea-orm · error

Failed to get time array

Error message

Failed to get time array

What it means

This panic comes from an `.expect("Failed to get time array")` inside ProxyRow's column decoding in the Postgres driver. `row.try_get::<Option<Vec<chrono::NaiveTime>>, _>(c.ordinal())` returned an Err, meaning sqlx could not decode the column's raw data as a `Vec<chrono::NaiveTime>` for a column whose Postgres type was reported as `TIME[]`. The library expects `with-chrono` + `postgres-array` features and a TIME[] column whose elements sqlx can decode into NaiveTime.

Source

Thrown at sea-orm-sync/src/driver/sqlx_postgres.rs:800

                                }),
                        ),

                        #[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

  1. Verify the actual column type with `SELECT column_name, udt_name FROM information_schema.columns WHERE table_name = '...'` and confirm it is `time[]` (TIME[]), not timestamptz[] or a domain.
  2. Ensure the sea-orm-sync/sqlx features `with-chrono` and `postgres-array` are enabled and versions of sea-orm, sea-query, and sqlx are aligned (all use compatible sqlx).
  3. Run `cargo update`/pin sqlx to the version sea-orm expects so the Postgres TIME[] decoder for chrono::NaiveTime exists.
  4. If the column may be NULL or heterogeneous, select it with an explicit cast (`SELECT time_col::text[]`) and parse manually instead of relying on ProxyRow decoding.

Example fix

// before: migration changed column type, entity no longer matches
// SELECT slot_times FROM schedule; -- slot_times is now timestamp[]

// after: align schema or cast at query level
// ALTER TABLE schedule ALTER COLUMN slot_times TYPE time[] USING slot_times::time[];
// or: SELECT ARRAY(SELECT x::time FROM unnest(slot_times) x) AS slot_times FROM schedule;
Defensive patterns

Strategy: validation

Validate before calling

// before querying, confirm the column type matches the decoder
let ty: (String,) = sqlx::query_as(
    "SELECT udt_name FROM information_schema.columns WHERE table_name = $1 AND column_name = $2",
)
.bind("schedule").bind("slot_times").fetch_one(db).await?;
assert_eq!(ty.0, "_time", "slot_times must be time[] to decode as Vec<chrono::NaiveTime>");

Type guard

fn is_time_array_column(udt_name: &str) -> bool { udt_name == "_time" }

Try / catch

// ProxyRow panics via expect, so it cannot be caught; avoid by decoding yourself:
match row.try_get::<Option<Vec<chrono::NaiveTime>>, _>(idx) {
    Ok(v) => v,
    Err(e) => { log::error!("TIME[] decode failed: {e}"); return Err(DecodeError::TimeArray(e)); }
}

Prevention

When it happens

Trigger: Selecting a `TIME[]` column (e.g. via Entity find/raw query) through ProxyRow when the cell cannot be decoded as Vec<chrono::NaiveTime>: the column is actually TIMESTAMP[], TEXT[], or a custom domain over time; the value is NULL in a way sqlx surfaces as a decode error; or the sqlx Postgres decoder feature set does not cover the wire type.

Common situations: Schema drift (column changed from TIME[] to something else after a migration), reading a view or materialized view whose column type differs from the entity definition, custom Postgres domain types over time[], or a feature-flag/version combination where chrono decoding of TIME arrays is not compiled in on the sqlx side.

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


AI-assisted analysis of SeaQL/sea-orm@e29bcd1b41 (2026-09-10). Data as JSON: /api/errors/181e54b156c274d8. Report an issue: GitHub.