SeaQL/sea-orm · error
Failed to get timestamp
Error message
Failed to get timestamp
What it means
ProxyRow decodes TIMESTAMP columns into chrono::NaiveDateTime (or time::PrimitiveDateTime when the with-time feature is used without with-chrono) and .expect("Failed to get timestamp") panics on sqlx decode failure. The panic means the column's wire type isn't a timezone-naive "timestamp without time zone" — most commonly it is actually timestamptz — or the chrono/time crate versions don't match sqlx's codec.
Source
Thrown at src/driver/sqlx_postgres.rs:717
),
#[cfg(all(feature = "with-mac_address", feature = "postgres-array"))]
"MACADDR[]" | "MACADDR8[]" => Value::Array(
sea_query::ArrayType::MacAddress,
row.try_get::<Option<Vec<mac_address::MacAddress>>, _>(c.ordinal())
.expect("Failed to get mac address array")
.map(|vals| {
Box::new(
vals.into_iter()
.map(|val| Value::MacAddress(Some(val)))
.collect(),
)
}),
),
#[cfg(feature = "with-chrono")]
"TIMESTAMP" => Value::ChronoDateTime(
row.try_get::<Option<chrono::NaiveDateTime>, _>(c.ordinal())
.expect("Failed to get timestamp"),
),
#[cfg(all(feature = "with-time", not(feature = "with-chrono")))]
"TIMESTAMP" => Value::TimeDateTime(
row.try_get::<Option<time::PrimitiveDateTime>, _>(c.ordinal())
.expect("Failed to get timestamp"),
),
#[cfg(all(feature = "with-chrono", feature = "postgres-array"))]
"TIMESTAMP[]" => Value::Array(
sea_query::ArrayType::ChronoDateTime,
row.try_get::<Option<Vec<chrono::NaiveDateTime>>, _>(c.ordinal())
.expect("Failed to get timestamp array")
.map(|vals| {
Box::new(
vals.into_iter()
.map(|val| Value::ChronoDateTime(Some(val)))
.collect(),
)View on GitHub (pinned to e29bcd1b41)
Solutions
- Check the column type: if it is timestamptz, alter the schema or the query (col::timestamp) so the wire type matches NaiveDateTime.
- Enable exactly one of with-chrono / with-time (the with-time arm only compiles when with-chrono is off) and confirm it matches your entity's value type.
- Run cargo tree -i chrono (and -i time) and pin single versions compatible with sqlx.
- In driver code, map the sqlx error to DbErr instead of .expect.
Example fix
// before
.expect("Failed to get timestamp")
// after
.map_err(|e| DbErr::TryIntoError { value_type: "timestamp".into(), source: e.into() })? Defensive patterns
Strategy: validation
Validate before calling
let udt: (String,) = sqlx::query_as(
"SELECT udt_name FROM information_schema.columns WHERE table_name=$1 AND column_name=$2",
)
.bind("my_table").bind("created_at").fetch_one(&pool).await?;
assert_eq!(udt.0, "timestamp", "use NaiveDateTime only for timestamp without time zone, got {}", udt.0); Type guard
fn is_naive_timestamp(udt_name: &str) -> bool { udt_name == "timestamp" } Prevention
- Never point the timestamp decode path at timestamptz columns
- Enable only one of with-chrono / with-time and match model types to it
- Pin single chrono/time versions compatible with sqlx
- Cast with ::timestamp in SQL when reading timestamptz through the proxy
When it happens
Trigger: Selecting a "TIMESTAMP" column that is truly TIMESTAMP WITH TIME ZONE (reported under a type name still handled here in some paths), or with both with-chrono and with-time enabled so NaiveDateTime decode mismatches; duplicate chrono major versions in the graph.
Common situations: Migrations created timestamptz but code assumed timestamp; chrono 0.4 vs sqlx expectation drift after Cargo update; reading from a view returning timestamptz.
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 timestamp
- Failed to get timestamp
- Failed to get uuid
- Failed to get uuid array
- Failed to get timestamp
AI-assisted analysis of SeaQL/sea-orm@e29bcd1b41 (2026-09-10).
Data as JSON: /api/errors/29b605c0abb93669.
Report an issue: GitHub.