{"record":{"id":"22f9d9d2cafa4bce","repo":"SeaQL/sea-orm","slug":"failed-to-get-timetz","errorCode":null,"errorMessage":"Failed to get timetz","messagePattern":"Failed to get timetz","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sea-orm-sync/src/driver/sqlx_postgres.rs","lineNumber":874,"sourceCode":"                            feature = \"postgres-array\"\n                        ))]\n                        \"TIMESTAMPTZ[]\" => Value::Array(\n                            sea_query::ArrayType::TimeDateTimeWithTimeZone,\n                            row.try_get::<Option<Vec<time::OffsetDateTime>>, _>(c.ordinal())\n                                .expect(\"Failed to get timestamptz array\")\n                                .map(|vals| {\n                                    Box::new(\n                                        vals.into_iter()\n                                            .map(|val| Value::TimeDateTimeWithTimeZone(Some(val)))\n                                            .collect(),\n                                    )\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                                }),","sourceCodeStart":856,"sourceCodeEnd":892,"githubUrl":"https://github.com/SeaQL/sea-orm/blob/e29bcd1b417c41a553b386fe94511d7c64a1c8ec/sea-orm-sync/src/driver/sqlx_postgres.rs#L856-L892","documentation":"Under `with-chrono`, a `TIMETZ` (time with time zone) column is decoded by ProxyRow into `chrono::NaiveTime` via `try_get::<Option<chrono::NaiveTime>>`; on a decode Err, `.expect(\"Failed to get timetz\")` panics. Note TIMETZ carries an offset that NaiveTime drops, so the mapping is inherently lossy and requires sqlx's timetz->NaiveTime decode path.","triggerScenarios":"Selecting a TIMETZ column when sqlx cannot decode it into NaiveTime: column is actually `time`/`timestamp`/text, a custom domain over timetz, or sqlx's chrono decoder for the timetz OID is unavailable at the compiled version.","commonSituations":"Tables using `time with time zone` (widely discouraged in Postgres); schema migration changing column type; sqlx/sea-orm version skew removing or gating the decoder.","solutions":["Prefer migrating the column to plain `time` (offsets in TIMETZ are legacy) so it maps cleanly to NaiveTime: `ALTER TABLE t ALTER COLUMN c TYPE time USING c AT TIME ZONE 'UTC';`","Verify the column udt_name is `timetz` and sqlx has its `chrono` feature enabled with a compatible version.","If the column is not timetz, fix the schema or adjust the query to cast (`c::timetz`).","Work around by selecting as text and parsing offset-aware with chrono yourself."],"exampleFix":"// before: legacy column\n// shift_start time with time zone\n\n// after\n// ALTER TABLE shifts ALTER COLUMN shift_start TYPE time USING shift_start AT TIME ZONE 'UTC';","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(\"shifts\").bind(\"shift_start\").fetch_one(db).await?;\nif ty.0 != \"timetz\" { return Err(anyhow!(\"shift_start is {}, expected timetz\", ty.0)); }","typeGuard":"fn is_timetz(udt_name: &str) -> bool { udt_name == \"timetz\" }","tryCatchPattern":"let t = row.try_get::<Option<chrono::NaiveTime>, _>(idx)\n    .map_err(|e| DecodeError::Timetz(e.to_string()))?;","preventionTips":["Avoid `time with time zone` columns entirely; Postgres itself discourages them","Migrate timetz -> time (offsets via AT TIME ZONE 'UTC') so chrono NaiveTime decodes directly","Enable `with-chrono` on sea-orm-sync and `chrono` on sqlx together","Verify column types after migrations with an information_schema assertion"],"tags":["postgres","decode","chrono","timetz","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"}