{"record":{"id":"ff17d2a4fa6e1ce9","repo":"SeaQL/sea-orm","slug":"failed-to-get-double-array","errorCode":null,"errorMessage":"Failed to get double array","messagePattern":"Failed to get double array","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sea-orm-sync/src/driver/sqlx_postgres.rs","lineNumber":533,"sourceCode":"                            row.try_get::<Option<Vec<f32>>, _>(c.ordinal())\n                                .expect(\"Failed to get float array\")\n                                .map(|vals| {\n                                    Box::new(\n                                        vals.into_iter()\n                                            .map(|val| Value::Float(Some(val)))\n                                            .collect(),\n                                    )\n                                }),\n                        ),\n\n                        \"FLOAT8\" | \"DOUBLE PRECISION\" => {\n                            Value::Double(row.try_get(c.ordinal()).expect(\"Failed to get double\"))\n                        }\n                        #[cfg(feature = \"postgres-array\")]\n                        \"FLOAT8[]\" | \"DOUBLE PRECISION[]\" => Value::Array(\n                            sea_query::ArrayType::Double,\n                            row.try_get::<Option<Vec<f64>>, _>(c.ordinal())\n                                .expect(\"Failed to get double array\")\n                                .map(|vals| {\n                                    Box::new(\n                                        vals.into_iter()\n                                            .map(|val| Value::Double(Some(val)))\n                                            .collect(),\n                                    )\n                                }),\n                        ),\n\n                        \"VARCHAR\" | \"CHAR\" | \"TEXT\" | \"NAME\" => Value::String(\n                            row.try_get::<Option<String>, _>(c.ordinal())\n                                .expect(\"Failed to get string\"),\n                        ),\n                        #[cfg(feature = \"postgres-array\")]\n                        \"VARCHAR[]\" | \"CHAR[]\" | \"TEXT[]\" | \"NAME[]\" => Value::Array(\n                            sea_query::ArrayType::String,\n                            row.try_get::<Option<Vec<String>>, _>(c.ordinal())\n                                .expect(\"Failed to get string array\")","sourceCodeStart":515,"sourceCodeEnd":551,"githubUrl":"https://github.com/SeaQL/sea-orm/blob/e29bcd1b417c41a553b386fe94511d7c64a1c8ec/sea-orm-sync/src/driver/sqlx_postgres.rs#L515-L551","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before: DB holds real[] but the entity says Vec<f64>\npub readings: Vec<f64>,\n\n// after: match the actual element type\npub readings: Vec<f32>,","handlingStrategy":"validation","validationCode":"let elem: (String,) = sqlx::query_as(\n    \"SELECT format_type(a.atttypid, a.atttypmod) FROM pg_attribute a WHERE a.attrelid = $1::regclass AND a.attname = $2\"\n).bind(\"my_table\").bind(\"readings\").fetch_one(&db).await?;\nassert_eq!(elem.0, \"double precision[]\", \"expected float8[]\");","typeGuard":"fn as_f64_array(v: &sea_orm::Value) -> Option<Vec<f64>> {\n    match v {\n        sea_orm::Value::Array(sea_orm::ArrayType::Double, items) => Some(\n            items.iter().filter_map(|x| match x {\n                sea_orm::Value::Double(d) => *d,\n                _ => None,\n            }).collect(),\n        ),\n        _ => None,\n    }\n}","tryCatchPattern":null,"preventionTips":["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."],"tags":["postgres","sqlx","array","type-mismatch","panic"],"backgroundTag":"type-mismatch","analyzedSha":"e29bcd1b417c41a553b386fe94511d7c64a1c8ec","analyzedAt":"2026-09-10T11:31:52.468Z","contentChangedAt":"2026-09-10T11:31:52.468Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}