{"record":{"id":"29b605c0abb93669","repo":"SeaQL/sea-orm","slug":"failed-to-get-timestamp-29b605","errorCode":null,"errorMessage":"Failed to get timestamp","messagePattern":"Failed to get timestamp","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/driver/sqlx_postgres.rs","lineNumber":717,"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":699,"sourceCodeEnd":735,"githubUrl":"https://github.com/SeaQL/sea-orm/blob/e29bcd1b417c41a553b386fe94511d7c64a1c8ec/src/driver/sqlx_postgres.rs#L699-L735","documentation":"ProxyRow decodes TIMESTAMP columns into chrono::NaiveDateTime (or time::PrimitiveDateTime when the with-time feature is used without with-chrono) and .expect(\"Failed to get timestamp\") panics on sqlx decode failure. The panic means the column's wire type isn't a timezone-naive \"timestamp without time zone\" — most commonly it is actually timestamptz — or the chrono/time crate versions don't match sqlx's codec.","triggerScenarios":"Selecting a \"TIMESTAMP\" column that is truly TIMESTAMP WITH TIME ZONE (reported under a type name still handled here in some paths), or with both with-chrono and with-time enabled so NaiveDateTime decode mismatches; duplicate chrono major versions in the graph.","commonSituations":"Migrations created timestamptz but code assumed timestamp; chrono 0.4 vs sqlx expectation drift after Cargo update; reading from a view returning timestamptz.","solutions":["Check the column type: if it is timestamptz, alter the schema or the query (col::timestamp) so the wire type matches NaiveDateTime.","Enable exactly one of with-chrono / with-time (the with-time arm only compiles when with-chrono is off) and confirm it matches your entity's value type.","Run cargo tree -i chrono (and -i time) and pin single versions compatible with sqlx.","In driver code, map the sqlx error to DbErr instead of .expect."],"exampleFix":"// before\n.expect(\"Failed to get timestamp\")\n// after\n.map_err(|e| DbErr::TryIntoError { value_type: \"timestamp\".into(), source: e.into() })?","handlingStrategy":"validation","validationCode":"let udt: (String,) = sqlx::query_as(\n    \"SELECT udt_name FROM information_schema.columns WHERE table_name=$1 AND column_name=$2\",\n)\n.bind(\"my_table\").bind(\"created_at\").fetch_one(&pool).await?;\nassert_eq!(udt.0, \"timestamp\", \"use NaiveDateTime only for timestamp without time zone, got {}\", udt.0);","typeGuard":"fn is_naive_timestamp(udt_name: &str) -> bool { udt_name == \"timestamp\" }","tryCatchPattern":null,"preventionTips":["Never point the timestamp decode path at timestamptz columns","Enable only one of with-chrono / with-time and match model types to it","Pin single chrono/time versions compatible with sqlx","Cast with ::timestamp in SQL when reading timestamptz through the proxy"],"tags":["rust","sqlx","postgres","chrono","timestamp"],"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"}