SeaQL/sea-orm · error
Failed to get double array
Error message
Failed to get double array
What it means
This panic comes from `.expect("Failed to get double array")` in `ProxyRow`, decoding a Postgres FLOAT8[]/DOUBLE PRECISION[] column as `Option<Vec<f64>>` (requires `postgres-array` feature). It fires when sqlx cannot decode the array into `Vec<f64>` because the actual array element type differs (e.g. float4[], numeric[]) or the value's type OID is not what sqlx expects. The `expect` turns the driver error into a hard panic.
Source
Thrown at sea-orm-sync/src/driver/sqlx_postgres.rs:533
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"),
),
#[cfg(feature = "postgres-array")]
"VARCHAR[]" | "CHAR[]" | "TEXT[]" | "NAME[]" => Value::Array(
sea_query::ArrayType::String,
row.try_get::<Option<Vec<String>>, _>(c.ordinal())
.expect("Failed to get string array")View on GitHub (pinned to e29bcd1b41)
Solutions
- Verify the real column type (`\d table`); align the entity field to it (Vec<f32> for float4[], Vec<f64> for float8[]).
- Force the type with a cast in the query: `SELECT col::DOUBLE PRECISION[] AS col`.
- Keep sea-orm and sqlx versions aligned and the `postgres-array` feature enabled.
- If elements may not all decode cleanly, switch the column to JSONB/TEXT and parse in Rust.
Example fix
// before: DB holds real[] but the entity says Vec<f64> pub readings: Vec<f64>, // after: match the actual element type pub readings: Vec<f32>,
Defensive patterns
Strategy: validation
Validate before calling
let elem: (String,) = sqlx::query_as(
"SELECT format_type(a.atttypid, a.atttypmod) FROM pg_attribute a WHERE a.attrelid = $1::regclass AND a.attname = $2"
).bind("my_table").bind("readings").fetch_one(&db).await?;
assert_eq!(elem.0, "double precision[]", "expected float8[]"); Type guard
fn as_f64_array(v: &sea_orm::Value) -> Option<Vec<f64>> {
match v {
sea_orm::Value::Array(sea_orm::ArrayType::Double, items) => Some(
items.iter().filter_map(|x| match x {
sea_orm::Value::Double(d) => *d,
_ => None,
}).collect(),
),
_ => None,
}
} Prevention
- Keep Vec<f64> fields strictly paired with float8[] columns; use Vec<f32> for float4[].
- Enable the `postgres-array` feature for array-typed entities.
- Re-verify entities after any ALTER COLUMN ... TYPE on arrays.
- Cast (::DOUBLE PRECISION[]) in raw queries when column types may drift.
When it happens
Trigger: Querying a table with a DOUBLE PRECISION[] column whose real element type is not float8 -- typically after `ALTER COLUMN ... TYPE REAL[]` or `NUMERIC[]`, or reading through a view/cast that changes the array type.
Common situations: Schema drift between entity `Vec<f64>` and DB `real[]`. Columns stored as numeric[] for precision then read with a float model. Version skew between sea-orm and sqlx altering array decode. Domain types over float8[] sqlx 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
- Failed to get float array
- Failed to get string array
- Failed to get double array
- Failed to get string array
- Failed to get float
AI-assisted analysis of SeaQL/sea-orm@e29bcd1b41 (2026-09-10).
Data as JSON: /api/errors/ff17d2a4fa6e1ce9.
Report an issue: GitHub.