{"record":{"id":"27da81e7553337b6","repo":"SeaQL/sea-orm","slug":"failed-to-get-numeric-27da81","errorCode":null,"errorMessage":"Failed to get numeric","messagePattern":"Failed to get numeric","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/driver/sqlx_postgres.rs","lineNumber":595,"sourceCode":"                        ),\n                        #[cfg(feature = \"postgres-array\")]\n                        \"BYTEA[]\" => Value::Array(\n                            sea_query::ArrayType::Bytes,\n                            row.try_get::<Option<Vec<Vec<u8>>>, _>(c.ordinal())\n                                .expect(\"Failed to get bytes array\")\n                                .map(|vals| {\n                                    Box::new(\n                                        vals.into_iter()\n                                            .map(|val| Value::Bytes(Some(val)))\n                                            .collect(),\n                                    )\n                                }),\n                        ),\n\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)))","sourceCodeStart":577,"sourceCodeEnd":613,"githubUrl":"https://github.com/SeaQL/sea-orm/blob/e29bcd1b417c41a553b386fe94511d7c64a1c8ec/src/driver/sqlx_postgres.rs#L577-L613","documentation":"This panic is raised by `.expect(\"Failed to get numeric\")` in ProxyRow for PostgreSQL (src/driver/sqlx_postgres.rs:595), in the `with-bigdecimal` feature branch. For NUMERIC columns the driver decodes `Option<bigdecimal::BigDecimal>`; if sqlx cannot convert the value into BigDecimal the expect panics. Frequently caused by precision/scale values sqlx's BigDecimal codec can't represent, or the column not really being numeric.","triggerScenarios":"Reading a NUMERIC column with extreme precision/scale (e.g. NUMERIC(100,50)) that bigdecimal's conversion rejects, a value stored as float8/text under a numeric type name, or `with-bigdecimal` enabled on sea-orm but sqlx compiled without the bigdecimal feature.","commonSituations":"Mixed feature flags between sea-orm and sqlx in Cargo.toml, decimal values from other clients with more digits than the decoder supports, schema drift where a numeric column was changed to double precision, or sqlx version mismatch.","solutions":["Ensure `with-bigdecimal` on sea-orm matches the sqlx `decimal-num-bigdecimal` feature and rebuild.","Check the actual column type and cast in SQL (`col::numeric`) or reduce precision/scale of the column definition.","Pin matching sea-orm/sqlx versions; numeric decoding changed between releases.","Try the alternative decoder: disable `with-bigdecimal` and use `with-rust_decimal` if your values fit rust_decimal's 96-bit range.","Log with RUST_LOG=sqlx=debug to see the underlying decode error before the panic."],"exampleFix":"// Cargo.toml: feature mismatch\n// before\nsea-orm = { version = \"1\", features = [\"sqlx-postgres\", \"with-bigdecimal\"] }\nsqlx = { version = \"0.8\", features = [\"postgres\"] } // missing bigdecimal support\n// after\nsqlx = { version = \"0.8\", features = [\"postgres\", \"decimal-num-bigdecimal\"] }","handlingStrategy":"validation","validationCode":"// Confirm feature alignment before compiling reads:\n// cargo tree -i bigdecimal  -- ensure one version shared by sea-orm and sqlx\n// Check column scale fits: SELECT numeric_scale FROM information_schema.columns\n//   WHERE table_name=$1 AND column_name=$2;","typeGuard":"fn is_numeric_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":["Keep sea-orm `with-bigdecimal` and sqlx bigdecimal features in sync.","Limit numeric precision/scale in schema definitions to what the decoder supports.","Cast numeric columns in SQL when precision is extreme.","Run cargo tree after upgrades to catch duplicate bigdecimal versions.","Read numeric as text and parse manually for pathological values."],"tags":["postgres","sqlx","numeric","bigdecimal","type-mismatch"],"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"}