{"record":{"id":"1b60f523ca4a178d","repo":"SeaQL/sea-orm","slug":"failed-to-get-time-1b60f5","errorCode":null,"errorMessage":"Failed to get time","messagePattern":"Failed to get time","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"sea-orm-sync/src/driver/sqlx_sqlite.rs","lineNumber":485,"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":467,"sourceCodeEnd":503,"githubUrl":"https://github.com/SeaQL/sea-orm/blob/e29bcd1b417c41a553b386fe94511d7c64a1c8ec/sea-orm-sync/src/driver/sqlx_sqlite.rs#L467-L503","documentation":"This panic happens in the SQLite driver when a column is reported as type TIME and the with-chrono feature is on. The driver calls row.try_get::<Option<NaiveTime>, _>(ordinal).expect(\"Failed to get time\") and panics because sqlx could not decode the stored value into a chrono NaiveTime. It signals that the column's declared type and its actual stored representation are inconsistent.","triggerScenarios":"Selecting from a SQLite table whose TIME column holds a value sqlx cannot decode as NaiveTime — e.g. '25:99:00', a full timestamp string in a TIME column, or a numeric value stored by another tool under TIME affinity.","commonSituations":"Hand-edited or imported SQLite data with malformed time strings; storing DATETIME values in TIME-typed columns; older schemas written by a different SQLite driver or ORM with a different time encoding.","solutions":["Inspect and fix the stored values to valid 'HH:MM:SS' time strings decodable as NaiveTime.","Change the column's declared type (e.g. to TEXT) so the driver stops attempting TIME decoding, or remap the entity field type to String and parse manually.","Rebuild the table through SeaORM migrations with the correct column type and reimport clean data.","Check whether values were written as full timestamps and either move them to a DATETIME column or strip the date part before insert."],"exampleFix":"// before: TIME column contains a full timestamp\n// sqlite> SELECT start_t FROM shifts;  => '2026-09-10 08:30:00'\n\n// after: store only the time component\n// sqlite> UPDATE shifts SET start_t = '08:30:00' WHERE id = 1;","handlingStrategy":"validation","validationCode":"// Check TIME columns contain only time-of-day strings before ORM reads\nlet bad: Vec<String> = sqlx::query_scalar(\n    \"SELECT start_t FROM shifts WHERE start_t NOT GLOB '[0-9][0-9]:[0-9][0-9]:[0-9][0-9]*'\")\n    .fetch_all(&pool).await?;\nassert!(bad.is_empty(), \"malformed TIME values: {:?}\", bad);","typeGuard":"fn parses_as_naive_time(s: &str) -> bool {\n    chrono::NaiveTime::parse_from_str(s, \"%H:%M:%S\").is_ok()\n}","tryCatchPattern":"// Isolate the panic on a thread since expect() aborts the normal error path\nlet res = std::thread::spawn(move || sync_query()).join();\nmatch res {\n    Ok(rows) => rows,\n    Err(_) => Err(Error::DbErrCustom(\"TIME column decode panic - stored value is not a valid NaiveTime\".into())),\n}","preventionTips":["Never store full timestamps in TIME-typed columns; use DATETIME instead","Normalize time strings to 'HH:MM:SS' on insert with application-side validation","Audit legacy tables with a GLOB/parse check before enabling ORM date/time features"],"tags":["sqlite","panic","time-parsing","type-decoding","database"],"backgroundTag":"invalid-date-format","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"}