{"record":{"id":"6825c8495eb1513a","repo":"SeaQL/sea-orm","slug":"failed-to-get-timetz-array","errorCode":null,"errorMessage":"Failed to get timetz array","messagePattern":"Failed to get timetz array","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sea-orm-sync/src/driver/sqlx_postgres.rs","lineNumber":885,"sourceCode":"                                    )\n                                }),\n                        ),\n\n                        #[cfg(feature = \"with-chrono\")]\n                        \"TIMETZ\" => Value::ChronoTime(\n                            row.try_get::<Option<chrono::NaiveTime>, _>(c.ordinal())\n                                .expect(\"Failed to get timetz\"),\n                        ),\n                        #[cfg(all(feature = \"with-time\", not(feature = \"with-chrono\")))]\n                        \"TIMETZ\" => {\n                            Value::TimeTime(row.try_get(c.ordinal()).expect(\"Failed to get timetz\"))\n                        }\n\n                        #[cfg(all(feature = \"with-chrono\", feature = \"postgres-array\"))]\n                        \"TIMETZ[]\" => Value::Array(\n                            sea_query::ArrayType::ChronoTime,\n                            row.try_get::<Option<Vec<chrono::NaiveTime>>, _>(c.ordinal())\n                                .expect(\"Failed to get timetz 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                        \"TIMETZ[]\" => Value::Array(\n                            sea_query::ArrayType::TimeTime,\n                            row.try_get::<Option<Vec<time::Time>>, _>(c.ordinal())\n                                .expect(\"Failed to get timetz array\")\n                                .map(|vals| {","sourceCodeStart":867,"sourceCodeEnd":903,"githubUrl":"https://github.com/SeaQL/sea-orm/blob/e29bcd1b417c41a553b386fe94511d7c64a1c8ec/sea-orm-sync/src/driver/sqlx_postgres.rs#L867-L903","documentation":"For `TIMETZ[]` columns under `with-chrono` + `postgres-array`, ProxyRow decodes `try_get::<Option<Vec<chrono::NaiveTime>>>`; a decode Err makes `.expect(\"Failed to get timetz array\")` panic. The array element type or encoding was not decodable as chrono NaiveTime.","triggerScenarios":"Selecting a timetz[] column when the element OID is actually `time[]`, `timestamp[]`, or text[]; or when sqlx's chrono array decoder for timetz elements is not available at the compiled versions.","commonSituations":"Array columns of legacy `time with time zone` values; migrations that changed element type; feature/dependency version skew between sea-orm, sea-query, and sqlx.","solutions":["Check udt_name equals `timetz[]`; if it is `time[]` or other, align schema or query mapping.","Migrate elements from timetz to plain time to match the NaiveTime mapping: rebuild the array with `AT TIME ZONE 'UTC'`.","Enable `with-chrono` + `postgres-array` on sea-orm-sync and matching sqlx `chrono` feature.","Cast to text[] in SQL and parse manually if the offsets must be retained."],"exampleFix":"// before: column is time[] but entity expects TIMETZ[] handling\n\n// after\n// ALTER TABLE t ALTER COLUMN c TYPE timetz[] USING c::timetz[];\n// -- or better, move to plain time[] and let chrono NaiveTime decode directly","handlingStrategy":"validation","validationCode":"let ty: (String,) = sqlx::query_as(\n    \"SELECT udt_name FROM information_schema.columns WHERE table_name = $1 AND column_name = $2\",\n).bind(\"t\").bind(\"c\").fetch_one(db).await?;\nassert_eq!(ty.0, \"_timetz\", \"c must be timetz[] to decode as Vec<chrono::NaiveTime>\");","typeGuard":"fn is_timetz_array(udt_name: &str) -> bool { udt_name == \"_timetz\" }","tryCatchPattern":"let vals = row.try_get::<Option<Vec<chrono::NaiveTime>>, _>(idx)\n    .map_err(|e| DecodeError::TimetzArray(e.to_string()))?;","preventionTips":["Confirm array element types (udt_name `_timetz`) before wiring entities to them","Prefer plain time[] over timetz[] in new schemas","Enable `with-chrono` + `postgres-array` features when temporal arrays are read","Guard schema drift with a CI schema-snapshot diff"],"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"}