{"record":{"id":"46f4493b55c48844","repo":"SeaQL/sea-orm","slug":"failed-to-get-time-46f449","errorCode":null,"errorMessage":"Failed to get time","messagePattern":"Failed to get time","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/driver/sqlx_postgres.rs","lineNumber":801,"sourceCode":"                            feature = \"postgres-array\"\n                        ))]\n                        \"DATE[]\" => Value::Array(\n                            sea_query::ArrayType::TimeDate,\n                            row.try_get::<Option<Vec<time::Date>>, _>(c.ordinal())\n                                .expect(\"Failed to get date array\")\n                                .map(|vals| {\n                                    Box::new(\n                                        vals.into_iter()\n                                            .map(|val| Value::TimeDate(Some(val)))\n                                            .collect(),\n                                    )\n                                }),\n                        ),\n\n                        #[cfg(feature = \"with-chrono\")]\n                        \"TIME\" => Value::ChronoTime(\n                            row.try_get::<Option<chrono::NaiveTime>, _>(c.ordinal())\n                                .expect(\"Failed to get time\"),\n                        ),\n                        #[cfg(all(feature = \"with-time\", not(feature = \"with-chrono\")))]\n                        \"TIME\" => Value::TimeTime(\n                            row.try_get::<Option<time::Time>, _>(c.ordinal())\n                                .expect(\"Failed to get time\"),\n                        ),\n\n                        #[cfg(all(feature = \"with-chrono\", feature = \"postgres-array\"))]\n                        \"TIME[]\" => Value::Array(\n                            sea_query::ArrayType::ChronoTime,\n                            row.try_get::<Option<Vec<chrono::NaiveTime>>, _>(c.ordinal())\n                                .expect(\"Failed to get time array\")\n                                .map(|vals| {\n                                    Box::new(\n                                        vals.into_iter()\n                                            .map(|val| Value::ChronoTime(Some(val)))\n                                            .collect(),\n                                    )","sourceCodeStart":783,"sourceCodeEnd":819,"githubUrl":"https://github.com/SeaQL/sea-orm/blob/e29bcd1b417c41a553b386fe94511d7c64a1c8ec/src/driver/sqlx_postgres.rs#L783-L819","documentation":"Panic raised by `.expect()` when SeaORM's Postgres ProxyRow conversion decodes a column whose type string is `TIME` as `Option<chrono::NaiveTime>` (chrono branch) or `Option<time::Time>` (time branch). A sqlx decode failure — the actual wire type isn't `time`, or the needed decode impl isn't compiled — produces the panic \"Failed to get time\".","triggerScenarios":"Selecting a TIME column through ProxyRow where the value cannot decode to `NaiveTime`/`time::Time` — e.g. the column is actually `timetz` (time with time zone), `timestamp`, or a domain over time, or the chrono/time feature decode impls are absent at compile time.","commonSituations":"Columns declared `TIME WITH TIME ZONE` that the metadata string still reports as `TIME`; expressions like `now()` typed as timestamp; feature-flag drift after switching date-time crates; Postgres/sea-orm version mismatches.","solutions":["Check the column's true type; if it is `timetz`, change the schema to `time` or cast: `col::time`.","Enable `with-chrono` (or `with-time`) so the matching decode impl is compiled into sea-orm.","Upgrade sea-orm/sqlx together for correct Postgres time decoding.","Select as text (`col::time::text`) and parse manually when type control isn't possible."],"exampleFix":"// before: column is TIMETZ, decode to NaiveTime panics\nlet rows = stmt.map(|row| row.into_proxy_row()).await?;\n\n// after\nlet stmt = Statement::from_string(\n    db.get_database_backend(),\n    \"SELECT start_at::time AS start_at FROM shifts\",\n);","handlingStrategy":"validation","validationCode":"let ty: Option<String> = sqlx::query_scalar(\n    \"SELECT data_type FROM information_schema.columns WHERE table_name=$1 AND column_name=$2\")\n    .bind(\"shifts\").bind(\"start_at\").fetch_optional(db).await?;\nassert_eq!(ty.as_deref(), Some(\"time without time zone\"));","typeGuard":"fn is_plain_time(data_type: &str) -> bool { data_type.eq_ignore_ascii_case(\"time without time zone\") }","tryCatchPattern":"// expect panics; validate the schema first. If unavoidable:\nlet decoded = std::panic::catch_unwind(AssertUnwindSafe(|| row.into_proxy_row()));\nif decoded.is_err() { eprintln!(\"TIME type mismatch (is it TIMETZ?)\"); }","preventionTips":["Avoid TIME WITH TIME ZONE columns; use plain time or cast ::time in queries.","Never select timestamp-typed expressions (e.g. now()) into TIME columns.","Enable with-chrono or with-time features explicitly.","Add CI checks that decode every temporal column through ProxyRow."],"tags":["postgres","sqlx","type-mismatch","time"],"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"}