{"record":{"id":"0bfa3379831a6be1","repo":"SeaQL/sea-orm","slug":"failed-to-get-float-array","errorCode":null,"errorMessage":"Failed to get float array","messagePattern":"Failed to get float array","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sea-orm-sync/src/driver/sqlx_postgres.rs","lineNumber":516,"sourceCode":"                            row.try_get::<Option<Vec<i64>>, _>(c.ordinal())\n                                .expect(\"Failed to get big integer array\")\n                                .map(|vals: Vec<i64>| {\n                                    Box::new(\n                                        vals.into_iter()\n                                            .map(|val| Value::BigInt(Some(val)))\n                                            .collect(),\n                                    )\n                                }),\n                        ),\n\n                        \"FLOAT4\" | \"REAL\" => {\n                            Value::Float(row.try_get(c.ordinal()).expect(\"Failed to get float\"))\n                        }\n                        #[cfg(feature = \"postgres-array\")]\n                        \"FLOAT4[]\" | \"REAL[]\" => Value::Array(\n                            sea_query::ArrayType::Float,\n                            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| {","sourceCodeStart":498,"sourceCodeEnd":534,"githubUrl":"https://github.com/SeaQL/sea-orm/blob/e29bcd1b417c41a553b386fe94511d7c64a1c8ec/sea-orm-sync/src/driver/sqlx_postgres.rs#L498-L534","documentation":"This panic comes from `.expect(\"Failed to get float array\")` in `ProxyRow`, where a Postgres column typed FLOAT4[]/REAL[] is decoded as `Option<Vec<f32>>` (behind the `postgres-array` feature). It fires when sqlx cannot decode the array's element type or shape into `Vec<f32>` -- typically because the actual array element OID differs (e.g. the column was changed to FLOAT8[] or a non-float array). Because the code uses `expect`, the failure panics instead of surfacing a driver error.","triggerScenarios":"Querying a table whose REAL[]/FLOAT4[] column cannot be decoded as Vec<f32>: the column is actually a different array type (FLOAT8[], NUMERIC[]), a partially-typed array, or the `postgres-array` feature decoding hits an element that sqlx rejects.","commonSituations":"Schema drift after `ALTER COLUMN ... TYPE DOUBLE PRECISION[]`; entity declares `Vec<f32>` but DB holds `float8[]`. Reading arrays through views or foreign tables with remapped types. Postgres domains over array types that sqlx cannot auto-decode.","solutions":["Check the true column type (`\\d table`) and make the entity field type match it exactly (Vec<f32> for float4[], Vec<f64> for float8[]).","Cast in the query to force the element type: `SELECT col::REAL[] AS col`.","Enable/keep the `postgres-array` feature enabled and ensure sea-orm and sqlx versions are in sync.","If the array may contain mixed/null elements, store it as JSONB or TEXT and parse in application code."],"exampleFix":"// before: DB column is float8[] but entity expects float array\npub samples: Vec<f32>,\n\n// after: match the actual array element type\npub samples: Vec<f64>,","handlingStrategy":"validation","validationCode":"let row: (String,) = sqlx::query_as(\n    \"SELECT data_type FROM information_schema.columns WHERE table_name = $1 AND column_name = $2\"\n).bind(\"my_table\").bind(\"samples\").fetch_one(&db).await?;\nassert_eq!(row.0, \"ARRAY\", \"expected an array column; confirm element type is float4 with pg_catalog\");\n// element check:\nlet 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(\"samples\").fetch_one(&db).await?;\nassert_eq!(elem.0, \"real[]\");","typeGuard":"fn as_f32_array(v: &sea_orm::Value) -> Option<Vec<f32>> {\n    match v {\n        sea_orm::Value::Array(sea_orm::ArrayType::Float, items) => Some(\n            items.iter().filter_map(|x| match x {\n                sea_orm::Value::Float(f) => *f,\n                _ => None,\n            }).collect(),\n        ),\n        _ => None,\n    }\n}","tryCatchPattern":null,"preventionTips":["Enable the `postgres-array` feature when entities use Vec<T> fields.","Match entity Vec element types exactly to the Postgres array element type (f32 for float4[], f64 for float8[]).","Avoid manual ALTERs on array columns without updating entities.","Use ::REAL[] casts in raw queries against uncertain columns."],"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"}