{"record":{"id":"181e54b156c274d8","repo":"SeaQL/sea-orm","slug":"failed-to-get-time-array","errorCode":null,"errorMessage":"Failed to get time array","messagePattern":"Failed to get time array","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sea-orm-sync/src/driver/sqlx_postgres.rs","lineNumber":800,"sourceCode":"                                }),\n                        ),\n\n                        #[cfg(feature = \"with-chrono\")]\n                        \"TIME\" => Value::ChronoTime(\n                            row.try_get::<Option<chrono::NaiveTime>, _>(c.ordinal())\n                                .expect(\"Failed to get time\"),\n                        ),\n                        #[cfg(all(feature = \"with-time\", not(feature = \"with-chrono\")))]\n                        \"TIME\" => Value::TimeTime(\n                            row.try_get::<Option<time::Time>, _>(c.ordinal())\n                                .expect(\"Failed to get time\"),\n                        ),\n\n                        #[cfg(all(feature = \"with-chrono\", feature = \"postgres-array\"))]\n                        \"TIME[]\" => Value::Array(\n                            sea_query::ArrayType::ChronoTime,\n                            row.try_get::<Option<Vec<chrono::NaiveTime>>, _>(c.ordinal())\n                                .expect(\"Failed to get time array\")\n                                .map(|vals| {\n                                    Box::new(\n                                        vals.into_iter()\n                                            .map(|val| Value::ChronoTime(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                        \"TIME[]\" => Value::Array(\n                            sea_query::ArrayType::TimeTime,\n                            row.try_get::<Option<Vec<time::Time>>, _>(c.ordinal())\n                                .expect(\"Failed to get time array\")\n                                .map(|vals| {","sourceCodeStart":782,"sourceCodeEnd":818,"githubUrl":"https://github.com/SeaQL/sea-orm/blob/e29bcd1b417c41a553b386fe94511d7c64a1c8ec/sea-orm-sync/src/driver/sqlx_postgres.rs#L782-L818","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["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.","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).","Run `cargo update`/pin sqlx to the version sea-orm expects so the Postgres TIME[] decoder for chrono::NaiveTime exists.","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."],"exampleFix":"// before: migration changed column type, entity no longer matches\n// SELECT slot_times FROM schedule; -- slot_times is now timestamp[]\n\n// after: align schema or cast at query level\n// ALTER TABLE schedule ALTER COLUMN slot_times TYPE time[] USING slot_times::time[];\n// or: SELECT ARRAY(SELECT x::time FROM unnest(slot_times) x) AS slot_times FROM schedule;","handlingStrategy":"validation","validationCode":"// before querying, confirm the column type matches the decoder\nlet ty: (String,) = sqlx::query_as(\n    \"SELECT udt_name FROM information_schema.columns WHERE table_name = $1 AND column_name = $2\",\n)\n.bind(\"schedule\").bind(\"slot_times\").fetch_one(db).await?;\nassert_eq!(ty.0, \"_time\", \"slot_times must be time[] to decode as Vec<chrono::NaiveTime>\");","typeGuard":"fn is_time_array_column(udt_name: &str) -> bool { udt_name == \"_time\" }","tryCatchPattern":"// ProxyRow panics via expect, so it cannot be caught; avoid by decoding yourself:\nmatch row.try_get::<Option<Vec<chrono::NaiveTime>>, _>(idx) {\n    Ok(v) => v,\n    Err(e) => { log::error!(\"TIME[] decode failed: {e}\"); return Err(DecodeError::TimeArray(e)); }\n}","preventionTips":["Pin sea-orm, sea-query, and sqlx to compatible versions in Cargo.toml","Add a migration/CI check that entity column types match information_schema","Keep `with-chrono` and `postgres-array` features enabled whenever TIME[] columns are used","Never alter array column element types without updating the corresponding entity"],"tags":["postgres","decode","chrono","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"}