{"record":{"id":"a0c896ecc9c1e7bd","repo":"SeaQL/sea-orm","slug":"failed-to-get-timestamptz-array","errorCode":null,"errorMessage":"Failed to get timestamptz array","messagePattern":"Failed to get timestamptz array","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sea-orm-sync/src/driver/sqlx_postgres.rs","lineNumber":844,"sourceCode":"\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)))\n                                        .collect(),\n                                )\n                            }),\n                        ),\n                        #[cfg(all(\n                            feature = \"with-time\",\n                            not(feature = \"with-chrono\"),\n                            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| {","sourceCodeStart":826,"sourceCodeEnd":862,"githubUrl":"https://github.com/SeaQL/sea-orm/blob/e29bcd1b417c41a553b386fe94511d7c64a1c8ec/sea-orm-sync/src/driver/sqlx_postgres.rs#L826-L862","documentation":"For a `TIMESTAMPTZ[]` column under `with-chrono` + `postgres-array`, ProxyRow decodes with `try_get::<Option<Vec<chrono::DateTime<chrono::Utc>>>>`; a decode Err triggers `.expect(\"Failed to get timestamptz array\")`. The array's element OID or encoding was not decodable as chrono DateTime<Utc> elements.","triggerScenarios":"Selecting a timestamptz[] column when the column is actually timestamp[] (different element OID), contains 'infinity' elements, or the sqlx array decoder for chrono timestamptz is not compiled/aligned.","commonSituations":"Array columns added by migrations with element type drift; chrono/time feature mixing; reading dumps where arrays were created as timestamp[] but typed as timestamptz[] in ORM metadata.","solutions":["Inspect udt_name of the column: it must be `timestamptz[]`; if it is `timestamp[]`, alter the column or the query mapping.","Replace 'infinity'/'-infinity' array elements with NULL or finite timestamps.","Enable `with-chrono` and `postgres-array` features and keep sea-orm/sea-query/sqlx versions matched.","Cast to text[] in SQL and parse manually if special values must be preserved."],"exampleFix":"// before\n// SELECT run_times FROM batches; -- run_times is timestamp[]\n\n// after\n// ALTER TABLE batches ALTER COLUMN run_times TYPE timestamptz[] USING run_times::timestamptz[];\n// or: SELECT ARRAY(SELECT x::timestamptz FROM unnest(run_times) x) AS run_times FROM batches;","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(\"batches\").bind(\"run_times\").fetch_one(db).await?;\nassert_eq!(ty.0, \"_timestamptz\", \"run_times must be timestamptz[]\");","typeGuard":"fn is_timestamptz_array(udt_name: &str) -> bool { udt_name == \"_timestamptz\" }","tryCatchPattern":"let vals = row.try_get::<Option<Vec<chrono::DateTime<chrono::Utc>>>, _>(idx)\n    .map_err(|e| DecodeError::TimestamptzArray(e.to_string()))?;","preventionTips":["Migrations that add array columns must specify timestamptz[] explicitly, not timestamp[]","Keep `with-chrono` + `postgres-array` enabled when temporal arrays are queried","Test entity reads against real schema snapshots in CI","Replace infinity elements with NULL before decode"],"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-14T11:17:12.474Z"}