{"record":{"id":"612270f0cbd27c10","repo":"SeaQL/sea-orm","slug":"failed-to-get-numeric-array-612270","errorCode":null,"errorMessage":"Failed to get numeric array","messagePattern":"Failed to get numeric array","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/driver/sqlx_postgres.rs","lineNumber":609,"sourceCode":"\n                        #[cfg(feature = \"with-bigdecimal\")]\n                        \"NUMERIC\" => Value::BigDecimal(\n                            row.try_get::<Option<bigdecimal::BigDecimal>, _>(c.ordinal())\n                                .expect(\"Failed to get numeric\"),\n                        ),\n                        #[cfg(all(\n                            feature = \"with-rust_decimal\",\n                            not(feature = \"with-bigdecimal\")\n                        ))]\n                        \"NUMERIC\" => {\n                            Value::Decimal(row.try_get(c.ordinal()).expect(\"Failed to get numeric\"))\n                        }\n\n                        #[cfg(all(feature = \"with-bigdecimal\", feature = \"postgres-array\"))]\n                        \"NUMERIC[]\" => Value::Array(\n                            sea_query::ArrayType::BigDecimal,\n                            row.try_get::<Option<Vec<bigdecimal::BigDecimal>>, _>(c.ordinal())\n                                .expect(\"Failed to get numeric array\")\n                                .map(|vals| {\n                                    Box::new(\n                                        vals.into_iter()\n                                            .map(|val| Value::BigDecimal(Some(val)))\n                                            .collect(),\n                                    )\n                                }),\n                        ),\n                        #[cfg(all(\n                            feature = \"with-rust_decimal\",\n                            not(feature = \"with-bigdecimal\"),\n                            feature = \"postgres-array\"\n                        ))]\n                        \"NUMERIC[]\" => Value::Array(\n                            sea_query::ArrayType::Decimal,\n                            row.try_get::<Option<Vec<rust_decimal::Decimal>>, _>(c.ordinal())\n                                .expect(\"Failed to get numeric array\")\n                                .map(|vals| {","sourceCodeStart":591,"sourceCodeEnd":627,"githubUrl":"https://github.com/SeaQL/sea-orm/blob/e29bcd1b417c41a553b386fe94511d7c64a1c8ec/src/driver/sqlx_postgres.rs#L591-L627","documentation":"This panic is raised by `.expect(\"Failed to get numeric array\")` in the `with-bigdecimal` + `postgres-array` branch of ProxyRow (src/driver/sqlx_postgres.rs:609). For NUMERIC[] columns the driver decodes `Option<Vec<bigdecimal::BigDecimal>>`; failure of sqlx to decode the array (wrong element type, missing feature, or oversized digits) panics.","triggerScenarios":"Reading NUMERIC[] where elements were produced as float8[] or text[], missing sqlx bigdecimal/arrays feature combination, or array elements with precision that the bigdecimal decoder path in that sqlx version cannot handle.","commonSituations":"Feature-flag combinations not enabled together (`postgres-array` + bigdecimal), sea-orm/sqlx version skew, schema drift converting numeric[] from other array types, or array_agg over numeric in an sqlx version without that array decode.","solutions":["Enable both `postgres-array` and `with-bigdecimal` on sea-orm and the corresponding sqlx features, then rebuild.","Verify element type (`SELECT array_typeof(col)`) and cast in SQL: `col::numeric[]`.","Pin compatible sea-orm/sqlx versions; numeric-array decoding changed across releases.","Use RUST_LOG=sqlx=debug to reveal the underlying decode error before the expect.","Map the failure to DbErr::Custom with the column ordinal instead of panicking."],"exampleFix":"// Cargo.toml\n// before\nsea-orm = { version = \"1\", features = [\"sqlx-postgres\", \"with-bigdecimal\"] }\n// after\nsea-orm = { version = \"1\", features = [\"sqlx-postgres\", \"with-bigdecimal\", \"postgres-array\"] }","handlingStrategy":"validation","validationCode":"// Verify numeric[] element type before reading:\n// SELECT array_typeof(col) FROM t LIMIT 1;  -- expect 'numeric'\n// Or cast: SELECT col::numeric[] FROM ...","typeGuard":"fn is_numeric_array_col(c: &ProxyColumn) -> bool {\n    c.ty == \"NUMERIC[]\"\n}","tryCatchPattern":"std::panic::catch_unwind(|| read_row(row))\n    .map_err(|p| DbErr::Custom(format!(\"numeric[] decode panic: {p:?}\")))?;","preventionTips":["Enable both `postgres-array` and `with-bigdecimal` features together.","Cast to ::numeric[] when the element type is uncertain.","Check array_typeof in validation queries.","Keep sea-orm/sqlx versions aligned.","Limit element precision where possible for reliable decoding."],"tags":["postgres","sqlx","array","numeric","bigdecimal"],"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"}