{"record":{"id":"d63d518b6473fde4","repo":"SeaQL/sea-orm","slug":"failed-to-get-time-d63d51","errorCode":null,"errorMessage":"Failed to get time","messagePattern":"Failed to get time","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"src/driver/sqlx_sqlite.rs","lineNumber":494,"sourceCode":"                                    .map(Box::new),\n                            )\n                        }\n                        #[cfg(all(feature = \"with-time\", not(feature = \"with-chrono\")))]\n                        \"DATE\" => {\n                            use time::Date;\n                            Value::TimeDate(\n                                row.try_get::<Option<Date>, _>(c.ordinal())\n                                    .expect(\"Failed to get date\")\n                                    .map(Box::new),\n                            )\n                        }\n\n                        #[cfg(feature = \"with-chrono\")]\n                        \"TIME\" => {\n                            use chrono::NaiveTime;\n                            Value::ChronoTime(\n                                row.try_get::<Option<NaiveTime>, _>(c.ordinal())\n                                    .expect(\"Failed to get time\")\n                                    .map(Box::new),\n                            )\n                        }\n                        #[cfg(all(feature = \"with-time\", not(feature = \"with-chrono\")))]\n                        \"TIME\" => {\n                            use time::Time;\n                            Value::TimeTime(\n                                row.try_get::<Option<Time>, _>(c.ordinal())\n                                    .expect(\"Failed to get time\")\n                                    .map(Box::new),\n                            )\n                        }\n\n                        _ => unreachable!(\"Unknown column type: {}\", c.type_info().name()),\n                    },\n                )\n            })\n            .collect(),","sourceCodeStart":476,"sourceCodeEnd":512,"githubUrl":"https://github.com/SeaQL/sea-orm/blob/e29bcd1b417c41a553b386fe94511d7c64a1c8ec/src/driver/sqlx_sqlite.rs#L476-L512","documentation":"This panic comes from an `.expect(\"Failed to get time\")` inside the SQLite row-decoding code (src/driver/sqlx_sqlite.rs:494). While converting a raw sqlx row into SeaORM `Value`s, a column declared `TIME` fails `row.try_get::<Option<NaiveTime>, _>()`, meaning the underlying sqlx value could not be decoded into a chrono NaiveTime. The library treats decoding failure as unrecoverable and panics instead of returning a DbErr.","triggerScenarios":"Selecting a SQLite `TIME` column (with the `with-chrono` feature) whose stored value cannot be decoded into NaiveTime, e.g. an out-of-range time like '25:00:00', a malformed text value, or a BLOB/INTEGER stored in a column the driver reports as TIME.","commonSituations":"SQLite is dynamically typed, so columns frequently hold values that don't match the declared schema; hand-inserted rows, data migrated from another tool, or a changed column type after table creation all cause this panic during `find()`/raw query mapping.","solutions":["Fix the data: correct or NULL out the malformed TIME values stored in the SQLite table.","Make the Rust model column a String (or ChronoDateTime with a supported format) so decoding matches what is actually stored.","Ensure the value is stored in a format sqlx's chrono support can decode (e.g. 'HH:MM:SS' text).","Enable the matching feature flag consistently (`with-chrono` vs `with-time`) so decoding and model types agree.","Query the column via a cast to TEXT in a raw query instead of relying on typed decoding."],"exampleFix":"// before\npub start_time: NaiveTime,\n// after (if the column stores arbitrary text)\n#[sea_orm(column_type = \"Time\")]\npub start_time: String,","handlingStrategy":"validation","validationCode":"// before fetching, verify the column holds decodable TIME values\nlet bad: Vec<_> = sqlx::query(\"SELECT rowid, cast(col AS TEXT) t FROM tbl WHERE col IS NOT NULL AND col GLOB '*[^0-9:. ]*' OR col GLOB '[0-9]*:[0-9]*:*' AND cast(col AS TEXT) > '23:59:59.999999'\")\n    .fetch_all(&pool).await?; if !bad.is_empty() { /* clean up rows */ }","typeGuard":"fn is_valid_sqlite_time(v: &str) -> bool {\n    time::Time::parse(v, \"%H:%M:%S%.f\").is_ok()\n}","tryCatchPattern":"// SeaORM panics; isolate the query and convert panic to error if needed\nlet result = std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| {\n    entity::Entity::find().all(db)\n}));","preventionTips":["Keep SQLite column storage classes aligned with the entity model's declared types","Validate imported/migrated data before querying with typed models","Enable exactly one of with-chrono / with-time and match model field types to it","Prefer TEXT/INTEGER storage with application-level parsing for heterogeneous legacy data"],"tags":["sqlite","decoding","chrono","panic","type-conversion"],"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"}