SeaQL/sea-orm · error
Failed to get timestamp
Error message
Failed to get timestamp
What it means
This panic comes from the `with-chrono` TIMESTAMP branch of `ProxyRow` in the MySQL driver: `sqlx::Row::try_get::<Option<chrono::DateTime<chrono::Utc>>, _>` failed for a column whose declared type is "TIMESTAMP". The `expect` turns the decode error into a panic with "Failed to get timestamp". It indicates the stored value cannot be decoded into a chrono UTC DateTime under the active feature configuration, often due to feature-flag or schema mismatch.
Source
Thrown at sea-orm-sync/src/driver/sqlx_mysql.rs:446
"BIT" | "BINARY" | "VARBINARY" | "TINYBLOB" | "BLOB" | "MEDIUMBLOB"
| "LONGBLOB" => Value::Bytes(
row.try_get::<Option<Vec<u8>>, _>(c.ordinal())
.expect("Failed to get bytes")
.map(Box::new),
),
"CHAR" | "VARCHAR" | "TINYTEXT" | "TEXT" | "MEDIUMTEXT" | "LONGTEXT" => {
Value::String(
row.try_get::<Option<String>, _>(c.ordinal())
.expect("Failed to get string")
.map(Box::new),
)
}
#[cfg(feature = "with-chrono")]
"TIMESTAMP" => Value::ChronoDateTimeUtc(
row.try_get::<Option<chrono::DateTime<chrono::Utc>>, _>(c.ordinal())
.expect("Failed to get timestamp")
.map(Box::new),
),
#[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")
.map(Box::new),
),
#[cfg(feature = "with-chrono")]
"DATE" => Value::ChronoDate(
row.try_get::<Option<chrono::NaiveDate>, _>(c.ordinal())
.expect("Failed to get date")
.map(Box::new),
),
#[cfg(all(feature = "with-time", not(feature = "with-chrono")))]
"DATE" => Value::TimeDate(
row.try_get::<Option<time::Date>, _>(c.ordinal())View on GitHub (pinned to e29bcd1b41)
Solutions
- Confirm the live column type is TIMESTAMP and refresh metadata if it changed.
- Verify feature flags are consistent: `with-chrono` vs `with-time` must not conflict across your dependency tree.
- Fix or exclude MySQL zero-dates ('0000-00-00 00:00:00'), which chrono cannot decode.
- Patch the driver to propagate DbErr instead of panicking to surface the underlying sqlx decode error.
Example fix
// before
"TIMESTAMP" => Value::ChronoDateTimeUtc(
row.try_get::<Option<chrono::DateTime<chrono::Utc>>, _>(c.ordinal())
.expect("Failed to get timestamp")
.map(Box::new),
)
// after
"TIMESTAMP" => Value::ChronoDateTimeUtc(
row.try_get::<Option<chrono::DateTime<chrono::Utc>>, _>(c.ordinal())
.map_err(|e| DbErr::TryGetErr(...))? // propagate instead of panicking
.map(Box::new),
) Defensive patterns
Strategy: validation
Validate before calling
// Check the column is TIMESTAMP and contains no zero-dates before querying assert_eq!(col.type_name, "TIMESTAMP"); // detect zero-dates: // SELECT COUNT(*) FROM t WHERE ts = '0000-00-00 00:00:00'; must be 0
Try / catch
// Guard the panic boundary since the driver uses expect:
std::panic::catch_unwind(|| proxy_row_from(&row, &columns))
.map_err(|_| DbErr::Custom("TIMESTAMP column decode failed".into()))? Prevention
- Keep `with-chrono` feature flags consistent across all crates in your dependency tree.
- Eliminate MySQL zero-dates by setting sql_mode to include NO_ZERO_DATE.
- Refresh table metadata after schema changes to TIMESTAMP columns.
- Match TIMESTAMP to ChronoDateTimeUtc mappings when using chrono features.
When it happens
Trigger: Reading a MySQL TIMESTAMP column while the crate is compiled with `with-chrono`, but the value cannot be decoded as `chrono::DateTime<Utc>` — e.g. metadata mismatch (column actually DATETIME/VARCHAR), or the crate was built with conflicting feature flags so the wrong branch matched.
Common situations: Mixing feature flags (`with-chrono` vs `with-time`) across crate versions; column altered from TIMESTAMP to another type while stale metadata is used; zero dates ('0000-00-00') in MySQL that chrono cannot decode.
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
AI-assisted analysis of SeaQL/sea-orm@e29bcd1b41 (2026-09-10).
Data as JSON: /api/errors/6209190556bf3ec7.
Report an issue: GitHub.