{"record":{"id":"020b6d84987fa0d7","repo":"SeaQL/sea-orm","slug":"failed-to-get-timestamp-array-020b6d","errorCode":null,"errorMessage":"Failed to get timestamp array","messagePattern":"Failed to get timestamp array","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/driver/sqlx_postgres.rs","lineNumber":729,"sourceCode":"                                }),\n                        ),\n\n                        #[cfg(feature = \"with-chrono\")]\n                        \"TIMESTAMP\" => Value::ChronoDateTime(\n                            row.try_get::<Option<chrono::NaiveDateTime>, _>(c.ordinal())\n                                .expect(\"Failed to get timestamp\"),\n                        ),\n                        #[cfg(all(feature = \"with-time\", not(feature = \"with-chrono\")))]\n                        \"TIMESTAMP\" => Value::TimeDateTime(\n                            row.try_get::<Option<time::PrimitiveDateTime>, _>(c.ordinal())\n                                .expect(\"Failed to get timestamp\"),\n                        ),\n\n                        #[cfg(all(feature = \"with-chrono\", feature = \"postgres-array\"))]\n                        \"TIMESTAMP[]\" => Value::Array(\n                            sea_query::ArrayType::ChronoDateTime,\n                            row.try_get::<Option<Vec<chrono::NaiveDateTime>>, _>(c.ordinal())\n                                .expect(\"Failed to get timestamp array\")\n                                .map(|vals| {\n                                    Box::new(\n                                        vals.into_iter()\n                                            .map(|val| Value::ChronoDateTime(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                        \"TIMESTAMP[]\" => Value::Array(\n                            sea_query::ArrayType::TimeDateTime,\n                            row.try_get::<Option<Vec<time::PrimitiveDateTime>>, _>(c.ordinal())\n                                .expect(\"Failed to get timestamp array\")\n                                .map(|vals| {","sourceCodeStart":711,"sourceCodeEnd":747,"githubUrl":"https://github.com/SeaQL/sea-orm/blob/e29bcd1b417c41a553b386fe94511d7c64a1c8ec/src/driver/sqlx_postgres.rs#L711-L747","documentation":"This is a panic (not a catchable error) raised by `.expect()` inside SeaORM's ProxyRow conversion for Postgres. When a column is reported as `TIMESTAMP[]`, the driver calls sqlx `try_get::<Option<Vec<chrono::NaiveDateTime>>>` on it; if sqlx cannot decode the column into that exact Rust type (type OID mismatch, NULL handling difference, or feature/crate version skew), it returns an Err and this expect panics with \"Failed to get timestamp array\". It almost always means the actual Postgres column type does not match what the string-matched branch assumed.","triggerScenarios":"Selecting a `TIMESTAMP[]` (timestamp without time zone array) column through the proxy row path while the `with-chrono` + `postgres-array` features are enabled, and sqlx refuses to decode the value into `Vec<chrono::NaiveDateTime>` — e.g. the column is actually `TIMESTAMPTZ[]`, the driver's type string matched wrongly, or a sqlx/chrono version mismatch changes decode support.","commonSituations":"Schema drift (column changed from TIMESTAMP[] to TIMESTAMPTZ[] or a domain over it), using `text[]`-typed placeholder results, mismatched sea-orm/sqlx minor versions where the chrono `NaiveDateTime` impl is feature-gated differently, or raw queries feeding ProxyRow whose declared types were derived from a different database backend.","solutions":["Verify the actual Postgres column type with `\\d table` and ensure it is exactly `timestamp[]` (not `timestamptz[]`); align the column or use the matching Value variant branch.","Pin compatible sea-orm / sea-orm-serde / sqlx versions in Cargo.lock so sqlx's chrono array decodes match what SeaORM expects.","Ensure the `with-chrono` and `postgres-array` features of sea-orm are enabled together so the correct decode branch is compiled in.","Avoid `.expect` by casting in SQL (`SELECT col::text[]`) or selecting the column as string when its type is uncertain."],"exampleFix":"// before: schema has TIMESTAMPTZ[] but code assumes TIMESTAMP[]\nlet rows: Vec<ProxyRow> = query.map(|row| row.into_proxy_row()).await?; // panics\n\n// after: normalize the column type in SQL\nlet rows = Statement::from_string(\n    db.get_database_backend(),\n    \"SELECT created_ats::timestamp[] AS created_ats FROM events\",\n);","handlingStrategy":"try-catch","validationCode":"// Before running the query, confirm the column type\nlet row: Option<String> = sqlx::query_scalar(\n    \"SELECT data_type || '[]' FROM information_schema.columns WHERE table_name=$1 AND column_name=$2\")\n    .bind(\"events\").bind(\"created_ats\").fetch_optional(db).await?;\nassert_eq!(row.as_deref(), Some(\"timestamp[]\"));","typeGuard":"fn is_timestamp_array(t: &str) -> bool { t.eq_ignore_ascii_case(\"timestamp[]\") }","tryCatchPattern":"// `.expect` panics and is not catchable safely; pre-validate the column type or\ncatch upstream via catch_unwind if unavoidable:\nlet result = std::panic::catch_unwind(|| build_proxy_rows(stmt));\nmatch result { Ok(rows) => rows, Err(_) => fallback_to_manual_decode() }","preventionTips":["Run `\\d table` or query information_schema to confirm array element types before decoding.","Cast TIMESTAMPTZ[] to timestamp[] explicitly in queries fed to ProxyRow.","Pin sea-orm and sqlx versions together and avoid mixed minor versions.","Keep feature flags (with-chrono, postgres-array) consistent across workspace crates."],"tags":["postgres","sqlx","type-mismatch","array-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-14T05:17:10.506Z"}