{"record":{"id":"44c7d60d91662c79","repo":"SeaQL/sea-orm","slug":"failed-to-get-timetz-array-44c7d6","errorCode":null,"errorMessage":"Failed to get timetz array","messagePattern":"Failed to get timetz array","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/driver/sqlx_postgres.rs","lineNumber":898,"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":880,"sourceCodeEnd":916,"githubUrl":"https://github.com/SeaQL/sea-orm/blob/e29bcd1b417c41a553b386fe94511d7c64a1c8ec/src/driver/sqlx_postgres.rs#L880-L916","documentation":"ProxyRow panics with this message when sqlx's `row.try_get::<Option<Vec<chrono::NaiveTime>>, _>` fails while converting a Postgres TIMETZ[] column into Value::Array during row conversion. try_get errors when the column is not actually a timetz array or the inner element decode fails. The expect() turns the sqlx decode error into a panic.","triggerScenarios":"Selecting a column that is declared/expected as TIMETZ[] but is actually a scalar timetz, a different array type (time[], text[]), or contains elements sqlx cannot decode into chrono::NaiveTime.","commonSituations":"Array-typed columns mapped with the wrong entity type; postgres-array feature enabled but the column is a one-dimensional vs multi-dimensional array sqlx rejects; migrations changed array element type; custom domains over timetz[].","solutions":["Verify the column type is exactly `timetz[]` (not `time[]` or scalar) via information_schema.columns.","Fix the entity field type to match (Vec<NaiveTime> for timetz[] with with-chrono, Vec<time::Time> with with-time) or regenerate entities.","Cast in the query if the source type differs: `SELECT my_arr::timetz[] FROM ...`.","Unwrap nested arrays in SQL (`unnest`) if the value is multi-dimensional.","Check that the postgres-array feature is enabled consistently across sea-orm/sea-query/sqlx."],"exampleFix":"// before: column is `time[]`, entity expects timetz[]\n// panic \"Failed to get timetz array\"\n\n// after: cast at query time\nlet rows = Task::find().statement(Statement::from_string(\n    DbBackend::Postgres,\n    \"SELECT id, slots::timetz[] AS slots FROM tasks\",\n)).into_proxy().all(db).await?;","handlingStrategy":"validation","validationCode":"let t = sqlx::query(\n    \"SELECT data_type, udt_name FROM information_schema.columns WHERE table_name=$1 AND column_name=$2\"\n).bind(\"shifts\").bind(\"slots\")\n .fetch_one(db).await?;\nassert_eq!(t.get::<String,_>(\"data_type\"), \"ARRAY\");\nassert_eq!(t.get::<String,_>(\"udt_name\"), \"_timetz\");","typeGuard":"fn is_timetz_array(c: &sea_orm::ColumnDef) -> bool {\n    matches!(c.get_column_type(), sea_query::ColumnType::Array(_))\n}","tryCatchPattern":"let decoded = std::panic::catch_unwind(|| {\n    // conversion that reads the timetz[] column\n});\nif decoded.is_err() {\n    return Err(DbErr::Custom(\"timetz[] column decode failed\".into()));\n}","preventionTips":["Confirm array element type (_timetz udt_name) before mapping to Vec<NaiveTime>/Vec<time::Time>.","Enable the postgres-array feature everywhere it is needed.","Avoid mixing scalar and array-typed columns under one entity field.","Cast arrays explicitly in raw SQL to guarantee the element type."],"tags":["postgres","sqlx","array","type-mismatch","decode"],"backgroundTag":"type-mismatch","analyzedSha":"e29bcd1b417c41a553b386fe94511d7c64a1c8ec","analyzedAt":"2026-09-10T11:31:52.468Z","contentChangedAt":"2026-09-10T11:31:52.468Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}