{"record":{"id":"50eae7a2e0bdc1a7","repo":"SeaQL/sea-orm","slug":"failed-to-get-unsigned-tiny-integer-50eae7","errorCode":null,"errorMessage":"Failed to get unsigned tiny integer","messagePattern":"Failed to get unsigned tiny integer","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/driver/sqlx_mysql.rs","lineNumber":401,"sourceCode":"pub(crate) fn from_sqlx_mysql_row_to_proxy_row(row: &sqlx::mysql::MySqlRow) -> crate::ProxyRow {\n    // https://docs.rs/sqlx-mysql/0.7.2/src/sqlx_mysql/protocol/text/column.rs.html\n    // https://docs.rs/sqlx-mysql/0.7.2/sqlx_mysql/types/index.html\n    use sea_query::Value;\n    use sqlx::{Column, Row, TypeInfo};\n    crate::ProxyRow {\n        values: row\n            .columns()\n            .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(","sourceCodeStart":383,"sourceCodeEnd":419,"githubUrl":"https://github.com/SeaQL/sea-orm/blob/e29bcd1b417c41a553b386fe94511d7c64a1c8ec/src/driver/sqlx_mysql.rs#L383-L419","documentation":"For MySQL columns named 'TINYINT UNSIGNED', the proxy row decoder calls row.try_get(c.ordinal()).expect(\"Failed to get unsigned tiny integer\"), assuming the value decodes as u8. A NULL value, or a mismatch between the reported type-info name and the actual stored Rust type, makes try_get fail and the expect panics.","triggerScenarios":"Selecting a nullable TINYINT UNSIGNED column through the sqlx MySQL proxy path; type_info().name() returns 'TINYINT UNSIGNED' but the underlying value cannot be decoded as u8 (NULL or driver representation change).","commonSituations":"Migrating sqlx versions where unsigned column representations changed; proxy/mock databases returning rows whose declared types don't match their payload types.","solutions":["Avoid NULLs on these columns (NOT NULL constraint) or decode as Option<u8> with a defined default.","Use SQL COALESCE/IFNULL to substitute 0 for NULL unsigned values.","Verify the type-info name strings against your sqlx version's MySQL type naming.","Convert the try_get error into a DbErr instead of panicking with expect."],"exampleFix":"// before\n\"TINYINT UNSIGNED\" => Value::TinyUnsigned(\n    row.try_get(c.ordinal()).expect(\"Failed to get unsigned tiny integer\")),\n// after\n\"TINYINT UNSIGNED\" => Value::TinyUnsigned(\n    row.try_get::<Option<u8>, _>(c.ordinal())\n        .map_err(|e| DbErr::Query(RuntimeErr::Protocol(e.to_string())))?\n        .unwrap_or(0)),","handlingStrategy":"validation","validationCode":"-- Ensure unsigned tinyint columns cannot be NULL:\nALTER TABLE items MODIFY retry_count TINYINT UNSIGNED NOT NULL DEFAULT 0;","typeGuard":"fn decodable_u8(col: &Column) -> bool {\n    col.type_info().name() == \"TINYINT UNSIGNED\" && !col.nullable()\n}","tryCatchPattern":"let converted = std::panic::catch_unwind(AssertUnwindSafe(|| ProxyRow::from_mysql_row(row, cols)));\nif converted.is_err() { return Err(DbErr::Query(RuntimeErr::Protocol(\"unsigned tinyint decode failed\".into()))); }","preventionTips":["Add NOT NULL constraints to unsigned columns","Coalesce NULL unsigned values to 0 in SELECTs","Verify sqlx version compatibility with sea-orm's type-name matching","Test proxy decoding against real MySQL schemas in CI"],"tags":["panic","mysql","type-decoding","sqlx"],"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"}