{"record":{"id":"3d6a386ffb33087e","repo":"SeaQL/sea-orm","slug":"failed-to-get-numeric-array","errorCode":null,"errorMessage":"Failed to get numeric array","messagePattern":"Failed to get numeric array","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"sea-orm-sync/src/driver/sqlx_postgres.rs","lineNumber":596,"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":578,"sourceCodeEnd":614,"githubUrl":"https://github.com/SeaQL/sea-orm/blob/e29bcd1b417c41a553b386fe94511d7c64a1c8ec/sea-orm-sync/src/driver/sqlx_postgres.rs#L578-L614","documentation":"This panic is raised inside sea-orm's Postgres row decoding when a NUMERIC[] (bigdecimal path) column cannot be converted to Option<Vec<bigdecimal::BigDecimal>>. sea-orm maps column types by their Postgres type name; `try_get` fails when sqlx's decoder cannot produce the requested Rust type (type mismatch, unexpected NULL representation, or a corrupted/unknown wire type). Because the code calls `.expect`, the underlying try_get error surfaces as a panic rather than a Result, aborting the thread doing the query.","triggerScenarios":"Executing a raw query or find() that selects a `NUMERIC[]` column while the `with-bigdecimal` and `postgres-array` features are enabled, when sqlx cannot decode the cell into Option<Vec<BigDecimal>>: e.g. the actual column type is not really NUMERIC[] (view/reporting column returning text or record), or a sqlx/pgtypes version mismatch means the BigDecimal decoder rejects the wire format (e.g. unusual scale/precision or NaN encoding).","commonSituations":"Selecting numeric[] columns via raw SQL in `Statement::from_string` queries where the declared type differs from the returned type; mixing sea-orm and sqlx minor versions with incompatible bigdecimal decoding; values like 'NaN' or 'Infinity' stored in numeric arrays that the decoder refuses; querying generated columns or views where the type OID doesn't match NUMERICARRAY.","solutions":["Verify the actual Postgres type of the column with `\\d table` or `SELECT pg_typeof(col)` and make sure it truly is `numeric[]`.","Enable the matching cargo features (`with-bigdecimal`, `postgres-array`) and keep sea-orm / sea-query / sqlx versions aligned in Cargo.lock (`cargo update -p` to a compatible set).","Cast the column in your SQL (`SELECT col::text[]` or `col::numeric[]`) so the returned type matches the decoder.","If values include NaN/Infinity, sanitize them in SQL (`NULLIF`) or decode as text and parse manually."],"exampleFix":"// before\nSELECT tags FROM stats; -- tags is actually text[], expected numeric[]\n\n// after\nSELECT tags::numeric[] AS tags FROM stats;","handlingStrategy":"validation","validationCode":"// Before running the query, verify column types:\nlet types: Vec<String> = db.query_all(Statement::from_string(\n    DatabaseBackend::Postgres,\n    \"SELECT format_type(a.atttypid, a.atttypmod) FROM pg_attribute a WHERE a.attrelid = 'my_table'::regclass AND a.attname = 'col'\",\n)).await?;\nassert_eq!(types[0].try_get::<_, String>(0)?, \"numeric[]\");","typeGuard":null,"tryCatchPattern":"// These panics use .expect, so they cannot be caught as Results.\n// Catch at the task boundary if you must keep running:\nlet result = std::panic::catch_unwind(std::panic::AssertUnwindSafe(||\n    entity::Entity::find().all(db)\n));\nmatch result {\n    Ok(rows) => { /* use rows */ }\n    Err(_) => { /* log and fall back to a text-cast query */ }\n}","preventionTips":["Verify the real column type with `SELECT pg_typeof(col)` before modeling it.","Keep sea-orm, sea-query, and sqlx versions pinned and consistent across the workspace.","Avoid SQL casts on columns fetched through entities.","Enable exactly the feature flags (with-bigdecimal, postgres-array) you use, in every crate."],"tags":["postgres","type-decoding","panic","numeric-array","sea-orm"],"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"}