{"record":{"id":"b2e938cb071e0cac","repo":"SeaQL/sea-orm","slug":"failed-to-get-unsigned-tiny-integer","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":"sea-orm-sync/src/driver/sqlx_mysql.rs","lineNumber":393,"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":375,"sourceCodeEnd":411,"githubUrl":"https://github.com/SeaQL/sea-orm/blob/e29bcd1b417c41a553b386fe94511d7c64a1c8ec/sea-orm-sync/src/driver/sqlx_mysql.rs#L375-L411","documentation":"In `from_sqlx_mysql_row_to_proxy_row`, a column typed \"TINYINT UNSIGNED\" is decoded with `row.try_get::<u8>` and `.expect(\"Failed to get unsigned tiny integer\")`. The panic fires when sqlx cannot decode the cell as u8 — typically a NULL value requested as a non-Option type, or a decode/type mismatch. This runs under the `proxy` feature when converting MySqlRows to ProxyRow.","triggerScenarios":"Proxy backend query against MySQL returning a TINYINT UNSIGNED column that is NULL, or whose actual value cannot be decoded into u8 (e.g. column type reported differently than the returned value after an expression/alias).","commonSituations":"Nullable unsigned tinyint columns (e.g. `age TINYINT UNSIGNED NULL`) in proxy result rows; UNION or CAST expressions changing the reported type; mismatched sqlx runtime vs compile-time type mapping.","solutions":["Make the column non-nullable or use COALESCE(col, 0) in the query.","Decode as `Option<u8>` and produce Value::TinyUnsigned(None) for NULLs.","Replace .expect with proper error propagation so the failing column is reported.","Align the sqlx version used at runtime with the one sea-orm was built against."],"exampleFix":"// before\n\"TINYINT UNSIGNED\" => Value::TinyUnsigned(\n    row.try_get(c.ordinal()).expect(\"Failed to get unsigned tiny integer\"),\n)\n// after: tolerate NULL\n\"TINYINT UNSIGNED\" => Value::TinyUnsigned(\n    row.try_get::<Option<u8>, _>(c.ordinal())\n        .expect(\"Failed to get unsigned tiny integer\"),\n)","handlingStrategy":"validation","validationCode":"// check NULL before decoding TINYINT UNSIGNED as u8\nif row.try_get_raw(c.ordinal())?.is_null() && c.type_info().name() == \"TINYINT UNSIGNED\" {\n    // handle NULL path\n}","typeGuard":null,"tryCatchPattern":"let v: Option<u8> = row.try_get(c.ordinal())?;","preventionTips":["Declare unsigned tinyint columns NOT NULL when a value is always expected.","Exercise proxy conversions with NULL-bearing fixtures.","Avoid SELECT expressions that change the effective column type.","Pin sqlx to sea-orm's tested version."],"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"}