{"record":{"id":"0afe307ecb7a6105","repo":"SeaQL/sea-orm","slug":"failed-to-get-unsigned-integer-0afe30","errorCode":null,"errorMessage":"Failed to get unsigned integer","messagePattern":"Failed to get unsigned integer","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/driver/sqlx_mysql.rs","lineNumber":409,"sourceCode":"            .iter()\n            .map(|c| {\n                (\n                    c.name().to_string(),\n                    match c.type_info().name() {\n                        \"TINYINT(1)\" | \"BOOLEAN\" => {\n                            Value::Bool(row.try_get(c.ordinal()).expect(\"Failed to get boolean\"))\n                        }\n                        \"TINYINT UNSIGNED\" => Value::TinyUnsigned(\n                            row.try_get(c.ordinal())\n                                .expect(\"Failed to get unsigned tiny integer\"),\n                        ),\n                        \"SMALLINT UNSIGNED\" => Value::SmallUnsigned(\n                            row.try_get(c.ordinal())\n                                .expect(\"Failed to get unsigned small integer\"),\n                        ),\n                        \"INT UNSIGNED\" => Value::Unsigned(\n                            row.try_get(c.ordinal())\n                                .expect(\"Failed to get unsigned integer\"),\n                        ),\n                        \"MEDIUMINT UNSIGNED\" | \"BIGINT UNSIGNED\" => Value::BigUnsigned(\n                            row.try_get(c.ordinal())\n                                .expect(\"Failed to get unsigned big integer\"),\n                        ),\n                        \"TINYINT\" => Value::TinyInt(\n                            row.try_get(c.ordinal())\n                                .expect(\"Failed to get tiny integer\"),\n                        ),\n                        \"SMALLINT\" => Value::SmallInt(\n                            row.try_get(c.ordinal())\n                                .expect(\"Failed to get small integer\"),\n                        ),\n                        \"INT\" => {\n                            Value::Int(row.try_get(c.ordinal()).expect(\"Failed to get integer\"))\n                        }\n                        \"MEDIUMINT\" | \"BIGINT\" => Value::BigInt(\n                            row.try_get(c.ordinal()).expect(\"Failed to get big integer\"),","sourceCodeStart":391,"sourceCodeEnd":427,"githubUrl":"https://github.com/SeaQL/sea-orm/blob/e29bcd1b417c41a553b386fe94511d7c64a1c8ec/src/driver/sqlx_mysql.rs#L391-L427","documentation":"This panic comes from an `.expect()` inside `ProxyRow`, SeaORM's proxy driver row-decoding path for MySQL. When the result-set column metadata says `INT UNSIGNED`, the code calls `row.try_get::<u32>` from sqlx; if the actual value cannot be decoded as an unsigned 32-bit integer (NULL, different real type, or corrupted wire data), sqlx returns a decode error and the `expect` panics with this message. It indicates a mismatch between the column type reported by the server and the value actually present in the row.","triggerScenarios":"Executing a query through the proxy driver (sea-orm `connect` with the mock/proxy runtime, e.g. testing with `ProxyQueryHandler`) where a column declared `INT UNSIGNED` in metadata contains NULL, or where the real column type drifted from the metadata (schema altered after the statement was described).","commonSituations":"Schema drift: a column was ALTERed from `INT UNSIGNED` to signed or NULLable after metadata was cached; hand-written SQL whose returned column no longer matches the entity definition; mock/proxy test handlers returning values of the wrong type for a declared `INT UNSIGNED` column.","solutions":["Make the column NOT NULL (or use `Option<u32>` in the entity) so a NULL cannot reach this decode path","Re-sync the entity definition with the live table schema (`sea-orm-cli generate entity`) so declared column types match reality","If using the proxy driver in tests, make the mock handler return the exact type declared for each column (u32 for INT UNSIGNED)","Update to a SeaORM/sqlx version matching your schema, since older drivers decoded MySQL unsigned types differently"],"exampleFix":"// before (entity on a NULLable INT UNSIGNED column)\npub count: u32,\n// after\npub count: Option<u32>,","handlingStrategy":"validation","validationCode":"// Before running raw queries against MySQL through SeaORM, verify column nullability/type\nlet stmt = \"SELECT IS_NULLABLE, COLUMN_TYPE FROM information_schema.COLUMNS \\\n            WHERE TABLE_SCHEMA = ? AND TABLE_NAME = ? AND COLUMN_NAME = ?\";\n// Assert COLUMN_TYPE == 'int unsigned' and IS_NULLABLE == 'NO' before selecting it into u32","typeGuard":"fn is_u32_compatible(col_type: &str, nullable: bool, value_is_null: bool) -> bool {\n    col_type.eq_ignore_ascii_case(\"int unsigned\") && !nullable && !value_is_null\n}","tryCatchPattern":null,"preventionTips":["Keep entity definitions in sync with migrations (regenerate after every ALTER)","Avoid NULLable columns in fields typed as plain integers","Use SeaORM entity queries rather than raw SQL so type mappings are handled for you","In proxy-driver tests, make mock rows match the declared column types exactly"],"tags":["mysql","sqlx","decoding","proxy-driver"],"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"}