SeaQL/sea-orm · error
Failed to get time
Error message
Failed to get time
What it means
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".
Source
Thrown at src/driver/sqlx_postgres.rs:801
feature = "postgres-array"
))]
"DATE[]" => Value::Array(
sea_query::ArrayType::TimeDate,
row.try_get::<Option<Vec<time::Date>>, _>(c.ordinal())
.expect("Failed to get date array")
.map(|vals| {
Box::new(
vals.into_iter()
.map(|val| Value::TimeDate(Some(val)))
.collect(),
)
}),
),
#[cfg(feature = "with-chrono")]
"TIME" => Value::ChronoTime(
row.try_get::<Option<chrono::NaiveTime>, _>(c.ordinal())
.expect("Failed to get time"),
),
#[cfg(all(feature = "with-time", not(feature = "with-chrono")))]
"TIME" => Value::TimeTime(
row.try_get::<Option<time::Time>, _>(c.ordinal())
.expect("Failed to get time"),
),
#[cfg(all(feature = "with-chrono", feature = "postgres-array"))]
"TIME[]" => Value::Array(
sea_query::ArrayType::ChronoTime,
row.try_get::<Option<Vec<chrono::NaiveTime>>, _>(c.ordinal())
.expect("Failed to get time array")
.map(|vals| {
Box::new(
vals.into_iter()
.map(|val| Value::ChronoTime(Some(val)))
.collect(),
)View on GitHub (pinned to e29bcd1b41)
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.
Example fix
// before: column is TIMETZ, decode to NaiveTime panics
let rows = stmt.map(|row| row.into_proxy_row()).await?;
// after
let stmt = Statement::from_string(
db.get_database_backend(),
"SELECT start_at::time AS start_at FROM shifts",
); Defensive patterns
Strategy: validation
Validate before calling
let ty: Option<String> = sqlx::query_scalar(
"SELECT data_type FROM information_schema.columns WHERE table_name=$1 AND column_name=$2")
.bind("shifts").bind("start_at").fetch_optional(db).await?;
assert_eq!(ty.as_deref(), Some("time without time zone")); Type guard
fn is_plain_time(data_type: &str) -> bool { data_type.eq_ignore_ascii_case("time without time zone") } Try / catch
// expect panics; validate the schema first. If unavoidable:
let decoded = std::panic::catch_unwind(AssertUnwindSafe(|| row.into_proxy_row()));
if decoded.is_err() { eprintln!("TIME type mismatch (is it TIMETZ?)"); } Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: Type mismatch errors: IllegalArgumentException, TypeError and type guards across 150 open-source libraries — this error's family across 150 libraries.
Related errors
- Failed to get time array
- Failed to get float
- Failed to get float array
- Failed to get double
- Failed to get double array
AI-assisted analysis of SeaQL/sea-orm@e29bcd1b41 (2026-09-10).
Data as JSON: /api/errors/46f4493b55c48844.
Report an issue: GitHub.