{"record":{"id":"dd6250ae6557acdf","repo":"SeaQL/sea-orm","slug":"failed-to-get-timestamp-dd6250","errorCode":null,"errorMessage":"Failed to get timestamp","messagePattern":"Failed to get timestamp","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sea-orm-sync/src/driver/sqlx_postgres.rs","lineNumber":704,"sourceCode":"                        ),\n                        #[cfg(all(feature = \"with-mac_address\", feature = \"postgres-array\"))]\n                        \"MACADDR[]\" | \"MACADDR8[]\" => Value::Array(\n                            sea_query::ArrayType::MacAddress,\n                            row.try_get::<Option<Vec<mac_address::MacAddress>>, _>(c.ordinal())\n                                .expect(\"Failed to get mac address array\")\n                                .map(|vals| {\n                                    Box::new(\n                                        vals.into_iter()\n                                            .map(|val| Value::MacAddress(Some(val)))\n                                            .collect(),\n                                    )\n                                }),\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                                    )","sourceCodeStart":686,"sourceCodeEnd":722,"githubUrl":"https://github.com/SeaQL/sea-orm/blob/e29bcd1b417c41a553b386fe94511d7c64a1c8ec/sea-orm-sync/src/driver/sqlx_postgres.rs#L686-L722","documentation":"This panic occurs in the PostgreSQL row-decoding path of sea-orm-sync's sqlx driver when a TIMESTAMP column cannot be decoded into chrono::NaiveDateTime. The driver matches on the PostgreSQL type name (\"TIMESTAMP\") and calls row.try_get::<Option<chrono::NaiveDateTime>>; sqlx returns a type-mismatch or decode error when the actual wire value is not compatible with the requested Rust type, and the .expect turns that into a panic. It almost always means the column's actual Postgres type differs from what the match arm assumed (e.g. TIMESTAMPTZ vs TIMESTAMP) or a required feature crate version mismatch.","triggerScenarios":"Reading a row where column c's Postgres type name is \"TIMESTAMP\" but the underlying value cannot be decoded as Option<chrono::NaiveDateTime>: e.g. the column is actually TIMESTAMPTZ, the driver matched a stale/aliased type string, or the with-chrono sqlx feature decoders conflict with the installed chrono version.","commonSituations":"Queries hitting columns defined as TIMESTAMPTZ (which some servers/drivers report differently), schema drift after a migration changed the column type, custom domain types over timestamp, or a chrono/sqlx version mismatch where sqlx's chrono impl is compiled for a different feature set.","solutions":["Check the actual column type in Postgres (\\d table or information_schema.columns) and ensure it is TIMESTAMP (without time zone); migrate to `ALTER COLUMN ... TYPE timestamp` if it is TIMESTAMPTZ.","Align sqlx and chrono versions/features so sqlx's `chrono` decode impl is enabled and compatible with the chrono crate sea-orm-sync links.","Catch the panic at a higher level by pre-validating result column types before hydrating ProxyRow, or patch the driver arm to try multiple types (TIMESTAMP/TIMESTAMPTZ).","If you control the query, cast in SQL: `SELECT col::timestamp FROM ...` to force a decodable type."],"exampleFix":"// before\nSELECT updated_at FROM events; -- updated_at is TIMESTAMPTZ -> panic \"Failed to get timestamp\"\n// after\nSELECT updated_at::timestamp AS updated_at FROM events;","handlingStrategy":"validation","validationCode":"-- run before hydration\nSELECT column_name, data_type FROM information_schema.columns\nWHERE table_name = 'your_table' AND data_type NOT IN ('timestamp without time zone');\n-- empty result = safe to decode TIMESTAMP columns as NaiveDateTime","typeGuard":"fn is_plain_timestamp(col: &PgTypeInfo) -> bool { col.name().eq_ignore_ascii_case(\"timestamp\") }","tryCatchPattern":"let ts = row.try_get::<Option<chrono::NaiveDateTime>, _>(idx)\n    .map_err(|e| DecodeError::Timestamp { column: idx, source: e })?;","preventionTips":["Use `timestamp without time zone` columns when decoding into NaiveDateTime","Cast ambiguous expressions (::timestamp) directly in SQL","Pin sqlx and chrono versions together in Cargo.toml","Smoke-test queries against real schema types in CI"],"tags":["postgres","sqlx","type-decode","timestamp","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"}