{"record":{"id":"37c3f50ba101fef0","repo":"SeaQL/sea-orm","slug":"failed-to-get-timestamptz-array-37c3f5","errorCode":null,"errorMessage":"Failed to get timestamptz array","messagePattern":"Failed to get timestamptz array","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/driver/sqlx_postgres.rs","lineNumber":857,"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":839,"sourceCodeEnd":875,"githubUrl":"https://github.com/SeaQL/sea-orm/blob/e29bcd1b417c41a553b386fe94511d7c64a1c8ec/src/driver/sqlx_postgres.rs#L839-L875","documentation":"ProxyRow panics because sqlx failed to decode a PostgreSQL TIMESTAMPTZ[] (array of timestamptz) column into `Option<Vec<chrono::DateTime<Utc>>>`. This arm only compiles with both `with-chrono` and `postgres-array` features; the `.expect` turns the sqlx decode error into an unrecoverable panic. Typical root causes are the element type not actually being timestamptz, a differently-shaped array, or unsupported sentinel elements.","triggerScenarios":"Fetching an array column (e.g. `timestamptz[]` in a model, or an aggregate like `array_agg(ts)` whose reported type is TIMESTAMPTZ[]) where the value cannot decode into Vec<DateTime<Utc>> — mismatched element types, multidimensional arrays, or `infinity` elements.","commonSituations":"array_agg/set-returning queries whose element type metadata is timestamptz[] but whose values are text; models typed `Vec<DateTime<Utc>>` against columns declared `text[]`; reading arrays through views; older sqlx versions with buggy PG array timestamp decoding.","solutions":["Confirm the column/expression is genuinely `timestamptz[]` (`\\d+ table` or information_schema); cast in SQL: `array_agg(ts)::timestamptz[]`.","Ensure both `with-chrono` and `postgres-array` features are enabled in all crates that touch the entity, with a single active chrono/time family.","Check array shape: multidimensional or mixed-type arrays won't decode; normalize the query (e.g. `unnest` or flatten) instead.","Replace `infinity`/`-infinity` elements with NULL or real timestamps.","Bump sea-orm/sqlx versions for known PG array decode fixes.","Workaround: select as `array_to_json(col)` or text and deserialize manually."],"exampleFix":"// before (element type reported as timestamptz[] but actually text[])\n\"SELECT array_agg(label) AS times FROM events\"\n\n// after\n\"SELECT array_agg(ts)::timestamptz[] AS times FROM events\"","handlingStrategy":"validation","validationCode":"// verify array element type before fetching\nlet elem = sqlx::query_scalar::<_, String>(\n    \"SELECT udt_name FROM information_schema.columns WHERE table_name=$1 AND column_name=$2\"\n).bind(table).bind(column).fetch_one(&db).await?;\nif elem != \"_timestamptz\" { return Err(AppError::SchemaMismatch(format!(\"expected _timestamptz, got {elem}\"))); }","typeGuard":"fn is_timestamptz_array(meta: &sea_orm::ColumnMeta) -> bool {\n    meta.col_type.as_str().eq_ignore_ascii_case(\"TIMESTAMPTZ[]\")\n}","tryCatchPattern":"let res = std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| {\n    entity::Entity::find().from_raw_sql(stmt).into_model::<M>().all(&db)\n}));\nlet rows = res.map_err(|_| AppError::DecodeFailed(\"timestamptz[] decode panicked\"))??;","preventionTips":["Enable both `with-chrono` and `postgres-array` features for array models.","Cast array_agg results: array_agg(ts)::timestamptz[].","Avoid multidimensional or mixed-type arrays in modeled columns.","Replace infinity sentinel elements with NULL.","Select array_to_json(col) and parse manually when shapes are uncertain."],"tags":["postgres","array","timestamptz","decode","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"}