{"record":{"id":"a8984e11bd147c3d","repo":"SeaQL/sea-orm","slug":"failed-to-get-boolean","errorCode":null,"errorMessage":"Failed to get boolean","messagePattern":"Failed to get boolean","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sea-orm-sync/src/driver/sqlx_mysql.rs","lineNumber":389,"sourceCode":"    }\n}\n\n#[cfg(feature = \"proxy\")]\npub(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(","sourceCodeStart":371,"sourceCodeEnd":407,"githubUrl":"https://github.com/SeaQL/sea-orm/blob/e29bcd1b417c41a553b386fe94511d7c64a1c8ec/sea-orm-sync/src/driver/sqlx_mysql.rs#L371-L407","documentation":"In `from_sqlx_mysql_row_to_proxy_row`, a column whose sqlx type info is \"TINYINT(1)\" or \"BOOLEAN\" is decoded with `row.try_get::<bool>` and `.expect(\"Failed to get boolean\")`. The panic fires when sqlx cannot decode the cell value as a bool — most often because the value is NULL but the code requests a non-Option bool, or the underlying type/decode mismatch. This happens in the `proxy` feature when converting raw MySqlRows into ProxyRow.","triggerScenarios":"Executing a query through the proxy database backend (proxy feature) against MySQL where a TINYINT(1)/BOOLEAN column contains NULL, or sqlx's decoder rejects the wire value (e.g. unexpected column type after `CAST`/expressions in the SELECT).","commonSituations":"Proxy-style databases wrapping MySQL where a nullable `is_active BOOLEAN` column is NULL in a result row; SELECT expressions like `SELECT flag IS TRUE` returning unexpected types; sqlx version changes altering type_info names so a branch mismatches the actual value type.","solutions":["Make the column non-nullable in the query (COALESCE) or in the schema if a bool is expected.","Handle NULL by decoding as Option in the proxy conversion (decode `Option<bool>` and map to Value::Bool(None)).","Check `row.try_get` errors instead of `.expect` to surface a DbErr with the column name.","Verify the sqlx version matches what sea-orm was compiled against; type_info names differ across versions."],"exampleFix":"// before\n\"TINYINT(1)\" | \"BOOLEAN\" => Value::Bool(\n    row.try_get(c.ordinal()).expect(\"Failed to get boolean\")\n)\n// after: tolerate NULL\n\"TINYINT(1)\" | \"BOOLEAN\" => Value::Bool(\n    row.try_get::<Option<bool>, _>(c.ordinal())\n        .expect(\"Failed to get boolean\")\n)","handlingStrategy":"validation","validationCode":"// before consuming proxy results, check the column for NULL\nif row.try_get_raw(c.ordinal())?.is_null() && matches!(c.type_info().name(), \"TINYINT(1)\" | \"BOOLEAN\") {\n    // handle NULL path instead of decoding a bare bool\n}","typeGuard":null,"tryCatchPattern":"// decode as Option to avoid the panic on NULL\nlet v: Option<bool> = row.try_get(c.ordinal())?;","preventionTips":["Make boolean columns NOT NULL or select COALESCE(flag, 0).","Test proxy queries against rows containing NULLs.","Keep the sqlx runtime version aligned with sea-orm's compiled sqlx.","Prefer query APIs that surface DbErr over the raw proxy row conversion."],"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"}