{"record":{"id":"7797b160005e7414","repo":"SeaQL/sea-orm","slug":"failed-to-get-decimal-7797b1","errorCode":null,"errorMessage":"Failed to get decimal","messagePattern":"Failed to get decimal","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/driver/sqlx_mysql.rs","lineNumber":525,"sourceCode":"                                .map(Box::new),\n                        ),\n                        #[cfg(all(feature = \"with-time\", not(feature = \"with-chrono\")))]\n                        \"YEAR\" => Value::TimeDate(\n                            row.try_get::<Option<time::Date>, _>(c.ordinal())\n                                .expect(\"Failed to get year\")\n                                .map(Box::new),\n                        ),\n\n                        \"ENUM\" | \"SET\" | \"GEOMETRY\" => Value::String(\n                            row.try_get::<Option<String>, _>(c.ordinal())\n                                .expect(\"Failed to get serialized string\")\n                                .map(Box::new),\n                        ),\n\n                        #[cfg(feature = \"with-bigdecimal\")]\n                        \"DECIMAL\" => Value::BigDecimal(\n                            row.try_get::<Option<bigdecimal::BigDecimal>, _>(c.ordinal())\n                                .expect(\"Failed to get decimal\")\n                                .map(Box::new),\n                        ),\n                        #[cfg(all(\n                            feature = \"with-rust_decimal\",\n                            not(feature = \"with-bigdecimal\")\n                        ))]\n                        \"DECIMAL\" => Value::Decimal(\n                            row.try_get::<Option<rust_decimal::Decimal>, _>(c.ordinal())\n                                .expect(\"Failed to get decimal\")\n                                .map(Box::new),\n                        ),\n\n                        #[cfg(feature = \"with-json\")]\n                        \"JSON\" => Value::Json(\n                            row.try_get::<Option<serde_json::Value>, _>(c.ordinal())\n                                .expect(\"Failed to get json\")\n                                .map(Box::new),\n                        ),","sourceCodeStart":507,"sourceCodeEnd":543,"githubUrl":"https://github.com/SeaQL/sea-orm/blob/e29bcd1b417c41a553b386fe94511d7c64a1c8ec/src/driver/sqlx_mysql.rs#L507-L543","documentation":"This panic is raised by `.expect(\"Failed to get decimal\")` in the sqlx MySQL driver's ProxyRow conversion when a column typed DECIMAL is decoded into `Option<bigdecimal::BigDecimal>` (behind the `with-bigdecimal` feature). If sqlx cannot decode the column value as a BigDecimal (e.g. the value's actual runtime type differs from what the type_info suggested, or the column holds a value BigDecimal cannot parse), the expect panics. It means the fetched DECIMAL value could not be materialized into the configured decimal crate type.","triggerScenarios":"Querying a MySQL DECIMAL (or NUMERIC) column while sea-orm is built with `with-bigdecimal`, and `row.try_get::<Option<bigdecimal::BigDecimal>, _>(c.ordinal())` returns a sqlx decode error -- typically a type mismatch between the wire value and BigDecimal.","commonSituations":"Mixed sqlx/sea-orm feature sets where bigdecimal versions diverge between dependencies; DECIMAL columns with unusual precision that overflow the configured scale; selecting DECIMAL via raw SQL proxy queries; switching from rust_decimal to bigdecimal (or vice versa) so the runtime value no longer matches the expected type.","solutions":["Make sure only one decimal feature (`with-bigdecimal` or `with-rust_decimal`) is enabled consistently across sea-orm, sea-orm-cli, and your code, so generated entity types match the runtime decode path.","Align bigdecimal crate versions between sea-orm and sqlx in Cargo.lock (`cargo update -p bigdecimal --precise <compatible-version>`).","Cast the column in SQL: `CAST(col AS CHAR)` and parse manually if the value has exotic scale/precision.","Verify entity column types use Decimal and match the schema; regenerate entities with sea-orm-cli using the same feature flags.","If precision/scale overflows, increase the decimal scale in the entity definition or round in SQL (`ROUND(col, n)`)."],"exampleFix":"// Cargo.toml before (mixed features)\nsea-orm = { version = \"1\", features = [\"sqlx-mysql\", \"with-bigdecimal\", \"with-rust_decimal\"] }\n\n// after (single decimal feature)\nsea-orm = { version = \"1\", features = [\"sqlx-mysql\", \"with-rust_decimal\"] }","handlingStrategy":"validation","validationCode":"// Verify schema precision fits the configured decimal type:\nlet res = db.query_all(Statement::from_string(\n    DatabaseBackend::MySql,\n    \"SELECT COLUMN_NAME, NUMERIC_PRECISION, NUMERIC_SCALE FROM information_schema.COLUMNS\n     WHERE TABLE_NAME = 'orders' AND DATA_TYPE = 'decimal'\n       AND NUMERIC_PRECISION > 28\",\n)).await?;\nif !res.is_empty() {\n    // cast these columns in SQL (CAST(col AS DECIMAL(28,8))) or switch to with-bigdecimal\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Enable exactly one decimal feature (with-bigdecimal XOR with-rust_decimal) across all crates.","Match DECIMAL precision/scale in the schema to the Rust decimal type limits.","Keep bigdecimal versions aligned between sea-orm and sqlx.","Regenerate entities with sea-orm-cli using the same features used at runtime."],"tags":["mysql","sqlx","decimal","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"}