SeaQL/sea-orm · error
Failed to get double
Error message
Failed to get double
What it means
This panic comes from `.expect("Failed to get double")` in `ProxyRow`, where a Postgres column typed FLOAT8/DOUBLE PRECISION is decoded via `row.try_get` into an `Option<f64>`. It fires when sqlx's decode fails for that column -- the runtime column type OID does not match `float8` (e.g. the column is actually NUMERIC or REAL), or a domain/extension type reports a matching name but a different wire format. Since `expect` is used, the panic aborts the query rather than returning an error.
Source
Thrown at sea-orm-sync/src/driver/sqlx_postgres.rs:527
"FLOAT4" | "REAL" => {
Value::Float(row.try_get(c.ordinal()).expect("Failed to get float"))
}
#[cfg(feature = "postgres-array")]
"FLOAT4[]" | "REAL[]" => Value::Array(
sea_query::ArrayType::Float,
row.try_get::<Option<Vec<f32>>, _>(c.ordinal())
.expect("Failed to get float array")
.map(|vals| {
Box::new(
vals.into_iter()
.map(|val| Value::Float(Some(val)))
.collect(),
)
}),
),
"FLOAT8" | "DOUBLE PRECISION" => {
Value::Double(row.try_get(c.ordinal()).expect("Failed to get double"))
}
#[cfg(feature = "postgres-array")]
"FLOAT8[]" | "DOUBLE PRECISION[]" => Value::Array(
sea_query::ArrayType::Double,
row.try_get::<Option<Vec<f64>>, _>(c.ordinal())
.expect("Failed to get double array")
.map(|vals| {
Box::new(
vals.into_iter()
.map(|val| Value::Double(Some(val)))
.collect(),
)
}),
),
"VARCHAR" | "CHAR" | "TEXT" | "NAME" => Value::String(
row.try_get::<Option<String>, _>(c.ordinal())
.expect("Failed to get string"),View on GitHub (pinned to e29bcd1b41)
Solutions
- Confirm the actual column type in the database matches FLOAT8/DOUBLE PRECISION; ALTER the column or change the entity field to the matching Rust type (e.g. Decimal for NUMERIC).
- Cast in the SQL: `SELECT x::DOUBLE PRECISION AS x` so decode receives a float8.
- Update/align sea-orm and sqlx versions if a recent dependency bump changed type mappings.
- For NUMERIC precision requirements, enable `with-rust_decimal`/`with-bigdecimal` and map the field to a decimal type instead of f64.
Example fix
// before: model uses f64 but the column was altered to NUMERIC pub amount: f64, // after: map the NUMERIC column to a decimal type #[sea_orm(column_type = "Decimal(Some((10, 2)))")] pub amount: Decimal,
Defensive patterns
Strategy: validation
Validate before calling
let row: (String,) = sqlx::query_as(
"SELECT data_type FROM information_schema.columns WHERE table_name = $1 AND column_name = $2"
).bind("my_table").bind("amount").fetch_one(&db).await?;
assert!(matches!(row.0.as_str(), "double precision"), "amount must be DOUBLE PRECISION, got {}", row.0); Type guard
fn as_f64(v: &sea_orm::Value) -> Option<f64> {
match v {
sea_orm::Value::Double(x) => *x,
_ => None,
}
} Prevention
- Run all schema changes through SeaORM migrations to keep entity and column types in lockstep.
- Choose f64 only for float8 columns; use Decimal types for NUMERIC precision requirements.
- Check `\d table` after manual DB interventions in production.
- Use ::DOUBLE PRECISION casts in raw SQL when types are uncertain.
When it happens
Trigger: Any SeaORM query returning a DOUBLE PRECISION column that sqlx cannot decode as f64 -- usually because the column's real type was altered (e.g. to NUMERIC) after the entity/model was written, or the value arrives through a view/cast with a different type.
Common situations: `ALTER TABLE ... ALTER COLUMN x TYPE NUMERIC(10,2)` for money precision while the model still says f64. Columns exposed through views with implicit casts. sqlx/sea-orm version skew changing decode behavior. Domains over float8 that sqlx cannot decode natively.
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 float
- Failed to get float array
- Failed to get double array
- Failed to get string
- Failed to get string array
AI-assisted analysis of SeaQL/sea-orm@e29bcd1b41 (2026-09-10).
Data as JSON: /api/errors/371edfe7ea59fc02.
Report an issue: GitHub.