{"record":{"id":"4ec1ba791d434817","repo":"SeaQL/sea-orm","slug":"failed-to-get-unsigned-integer","errorCode":null,"errorMessage":"Failed to get unsigned integer","messagePattern":"Failed to get unsigned integer","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sea-orm-sync/src/driver/sqlx_mysql.rs","lineNumber":401,"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":383,"sourceCodeEnd":419,"githubUrl":"https://github.com/SeaQL/sea-orm/blob/e29bcd1b417c41a553b386fe94511d7c64a1c8ec/sea-orm-sync/src/driver/sqlx_mysql.rs#L383-L419","documentation":"In `from_sqlx_mysql_row_to_proxy_row`, a column typed \"INT UNSIGNED\" is decoded with `row.try_get::<u32>` and `.expect(\"Failed to get unsigned integer\")`. The panic fires when sqlx cannot decode the cell as u32 — typically a NULL requested as non-Option u32, or a reported/actual type mismatch in the row.","triggerScenarios":"Proxy backend query against MySQL returning an INT UNSIGNED column that is NULL, or a value that fails u32 decoding due to expression/CAST type changes.","commonSituations":"Nullable INT UNSIGNED columns (e.g. counters) read through the proxy backend; aggregate or aliased expressions whose type_info differs from the raw value; sqlx runtime/compile-time version mismatch.","solutions":["Make the column non-nullable or use COALESCE(col, 0).","Decode as `Option<u32>` and map NULL to Value::Unsigned(None).","Surface try_get errors as DbErr with column context instead of .expect.","Check sqlx version compatibility with the sea-orm build."],"exampleFix":"// before\n\"INT UNSIGNED\" => Value::Unsigned(\n    row.try_get(c.ordinal()).expect(\"Failed to get unsigned integer\"),\n)\n// after: tolerate NULL\n\"INT UNSIGNED\" => Value::Unsigned(\n    row.try_get::<Option<u32>, _>(c.ordinal())\n        .expect(\"Failed to get unsigned integer\"),\n)","handlingStrategy":"validation","validationCode":"// check NULL before decoding INT UNSIGNED as u32\nif row.try_get_raw(c.ordinal())?.is_null() && c.type_info().name() == \"INT UNSIGNED\" {\n    // handle NULL path\n}","typeGuard":null,"tryCatchPattern":"let v: Option<u32> = row.try_get(c.ordinal())?;","preventionTips":["Use NOT NULL for unsigned int columns that should always have values.","COALESCE nullable counters in the query: COALESCE(cnt, 0).","Test the proxy path against NULL data.","Keep sqlx versions consistent across the workspace."],"tags":["mysql","sqlx","proxy","type-mismatch","null-value","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"}