SeaQL/sea-orm · critical
Failed to get date
Error message
Failed to get date
What it means
This panic occurs in sea-orm-sync's SQLite driver when converting a raw query result row into SeaORM Value objects. The column's declared type is "DATE" (with the with-chrono feature), and the driver calls row.try_get::<Option<NaiveDate>, _>(ordinal).expect("Failed to get date"), which panics when sqlx cannot decode the stored value into a chrono NaiveDate. This is a fail-fast invariant: the driver trusts that the SQLite column type string matches the actual runtime value encoding.
Source
Thrown at sea-orm-sync/src/driver/sqlx_sqlite.rs:466
.expect("Failed to get timestamp")
.map(Box::new),
)
}
#[cfg(all(feature = "with-time", not(feature = "with-chrono")))]
"DATETIME" => {
use time::OffsetDateTime;
Value::TimeDateTimeWithTimeZone(
row.try_get::<Option<OffsetDateTime>, _>(c.ordinal())
.expect("Failed to get timestamp")
.map(Box::new),
)
}
#[cfg(feature = "with-chrono")]
"DATE" => {
use chrono::NaiveDate;
Value::ChronoDate(
row.try_get::<Option<NaiveDate>, _>(c.ordinal())
.expect("Failed to get date")
.map(Box::new),
)
}
#[cfg(all(feature = "with-time", not(feature = "with-chrono")))]
"DATE" => {
use time::Date;
Value::TimeDate(
row.try_get::<Option<Date>, _>(c.ordinal())
.expect("Failed to get date")
.map(Box::new),
)
}
#[cfg(feature = "with-chrono")]
"TIME" => {
use chrono::NaiveTime;
Value::ChronoTime(
row.try_get::<Option<NaiveTime>, _>(c.ordinal())View on GitHub (pinned to e29bcd1b41)
Solutions
- Inspect the offending column's stored values (SELECT the raw value with sqlite3 CLI) and fix or reformat them into valid 'YYYY-MM-DD' strings that NaiveDate can parse.
- Alter the column's declared type to TEXT (or INTEGER) in the SQLite schema so the driver stops taking the DATE decode path, or use SeaORM's schema sync to recreate the table with the correct type.
- Recreate the table via SeaORM migrations/entities so the column type in SQLite matches the Rust model type, then repopulate the data.
- If you don't need date semantics, disable the with-chrono/with-time features so the column is read as a plain Value instead.
Example fix
// before: column declared DATE holds malformed data // sqlite> SELECT my_date FROM my_table; => '31/02/2026' // after: repair the data to an ISO date SQLite/sqlx can decode // sqlite> UPDATE my_table SET my_date = '2026-02-28' WHERE id = 1; // then re-run the query
Defensive patterns
Strategy: validation
Validate before calling
// Run before querying: confirm DATE columns hold ISO-8601 dates
let bad: Vec<String> = sqlx::query_scalar(
"SELECT my_date FROM my_table WHERE my_date IS NOT NULL AND my_date NOT GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]'")
.fetch_all(&pool).await?;
assert!(bad.is_empty(), "malformed DATE values: {:?}", bad); Type guard
fn is_valid_iso_date(s: &str) -> bool {
chrono::NaiveDate::parse_from_str(s, "%Y-%m-%d").is_ok()
} Try / catch
// Panics cannot be caught idiomatically; validate data instead.
// If you must isolate it, run the query on a worker thread and inspect the JoinError:
let res = std::thread::spawn(move || sync_query()).join();
match res {
Ok(v) => v,
Err(_) => return Err(Error::DbErrCustom("DATE column decode panic - check stored date format".into())),
} Prevention
- Validate imported/legacy data against ISO-8601 formats before pointing SeaORM at it
- Keep declared SQLite column types aligned with entity field types via migrations
- Decide on one date feature (with-chrono or with-time) and use it consistently across writes and reads
- Never hand-edit schema types with the sqlite3 CLI on tables managed by SeaORM
When it happens
Trigger: Executing a Select/Find query through the sync SQLite driver where a column is declared (or reported by SQLite) as type DATE, but the underlying stored value cannot be decoded as NaiveDate — e.g. a TEXT/NULL-incompatible blob, a malformed date string like '2026-13-45', or a value stored with the wrong affinity by a tool outside SeaORM.
Common situations: Migrating an existing SQLite database created by another ORM or hand-written SQL where DATE columns hold non-ISO strings; schema drift after renaming/altering columns with sqlite3 CLI; mixing the with-chrono feature with data written by the with-time codepath; bulk-loading data with sqlite3 .import that writes malformed dates.
Related errors
AI-assisted analysis of SeaQL/sea-orm@e29bcd1b41 (2026-09-10).
Data as JSON: /api/errors/f3bd9105ee07c4b6.
Report an issue: GitHub.