{"record":{"id":"c64c7eb7039c7da7","repo":"SeaQL/sea-orm","slug":"failed-to-get-timestamptz","errorCode":null,"errorMessage":"Failed to get timestamptz","messagePattern":"Failed to get timestamptz","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sea-orm-sync/src/driver/sqlx_postgres.rs","lineNumber":830,"sourceCode":"                            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| {\n                                    Box::new(\n                                        vals.into_iter()\n                                            .map(|val| Value::TimeTime(Some(val)))\n                                            .collect(),\n                                    )\n                                }),\n                        ),\n\n                        #[cfg(feature = \"with-chrono\")]\n                        \"TIMESTAMPTZ\" => Value::ChronoDateTimeUtc(\n                            row.try_get::<Option<chrono::DateTime<chrono::Utc>>, _>(c.ordinal())\n                                .expect(\"Failed to get timestamptz\"),\n                        ),\n                        #[cfg(all(feature = \"with-time\", not(feature = \"with-chrono\")))]\n                        \"TIMESTAMPTZ\" => Value::TimeDateTimeWithTimeZone(\n                            row.try_get::<Option<time::OffsetDateTime>, _>(c.ordinal())\n                                .expect(\"Failed to get timestamptz\"),\n                        ),\n\n                        #[cfg(all(feature = \"with-chrono\", feature = \"postgres-array\"))]\n                        \"TIMESTAMPTZ[]\" => Value::Array(\n                            sea_query::ArrayType::ChronoDateTimeUtc,\n                            row.try_get::<Option<Vec<chrono::DateTime<chrono::Utc>>>, _>(\n                                c.ordinal(),\n                            )\n                            .expect(\"Failed to get timestamptz array\")\n                            .map(|vals| {\n                                Box::new(\n                                    vals.into_iter()\n                                        .map(|val| Value::ChronoDateTimeUtc(Some(val)))","sourceCodeStart":812,"sourceCodeEnd":848,"githubUrl":"https://github.com/SeaQL/sea-orm/blob/e29bcd1b417c41a553b386fe94511d7c64a1c8ec/sea-orm-sync/src/driver/sqlx_postgres.rs#L812-L848","documentation":"Under the `with-chrono` feature, a column typed `TIMESTAMPTZ` is decoded with `try_get::<Option<chrono::DateTime<chrono::Utc>>>`; when sqlx returns a decode error, `.expect(\"Failed to get timestamptz\")` panics. This means the wire data for the column could not be interpreted as a timestamptz-compatible value.","triggerScenarios":"Selecting a TIMESTAMPTZ column via ProxyRow when the underlying column is actually TIMESTAMP (without tz) with an unexpected encoding, a custom type named TIMESTAMPTZ in a foreign schema, or sqlx's chrono decoding of that OID is unavailable.","commonSituations":"Schema drift after migrations, querying through FDWs/views where types resolve differently, Postgres/extension version changes, or sqlx version misalignment with sea-orm.","solutions":["Verify the column type is genuinely `timestamp with time zone` (`\\d table` or information_schema).","Enable `with-chrono` on sea-orm-sync and ensure sqlx is compiled with its `chrono` feature at a compatible version.","If the column is plain `timestamp`, either change the Rust mapping/query or alter the column to timestamptz.","As a fallback, cast in SQL (`col::timestamptz`) or select as text and parse with chrono."],"exampleFix":"// before: column is timestamp (no tz), decoded as DateTime<Utc> -> panic\n// SELECT created_at FROM events;\n\n// after\n// ALTER TABLE events ALTER COLUMN created_at TYPE timestamptz USING created_at AT TIME ZONE 'UTC';\n// or: SELECT created_at::timestamptz AS created_at FROM events;","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(\"events\").bind(\"created_at\").fetch_one(db).await?;\nif ty.0 != \"timestamptz\" { return Err(anyhow!(\"created_at is {} ({}), expected timestamptz\", ty.0, \"chrono decode will fail\")); }","typeGuard":"fn is_timestamptz(udt_name: &str) -> bool { udt_name == \"timestamptz\" }","tryCatchPattern":"// avoid the panic by decoding with error handling:\nlet ts = row.try_get::<Option<chrono::DateTime<chrono::Utc>>, _>(idx)\n    .map_err(|e| DecodeError::Timestamptz(e.to_string()))?;","preventionTips":["Standardize on timestamptz (not timestamp) for all instant columns","Keep `with-chrono` enabled on sea-orm-sync and `chrono` on sqlx","Check data for special values ('infinity') before enabling chrono decoding on legacy tables","Validate entity mappings against the live schema in integration tests"],"tags":["postgres","decode","chrono","timestamptz","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"}