{"record":{"id":"04e212e75377a1c9","repo":"SeaQL/sea-orm","slug":"failed-to-get-boolean-04e212","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_sqlite.rs","lineNumber":415,"sourceCode":"    }\n}\n\n#[cfg(feature = \"proxy\")]\npub(crate) fn from_sqlx_sqlite_row_to_proxy_row(row: &sqlx::sqlite::SqliteRow) -> crate::ProxyRow {\n    // https://docs.rs/sqlx-sqlite/0.7.2/src/sqlx_sqlite/type_info.rs.html\n    // https://docs.rs/sqlx-sqlite/0.7.2/sqlx_sqlite/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                        \"BOOLEAN\" => {\n                            Value::Bool(row.try_get(c.ordinal()).expect(\"Failed to get boolean\"))\n                        }\n\n                        \"INTEGER\" => {\n                            Value::Int(row.try_get(c.ordinal()).expect(\"Failed to get integer\"))\n                        }\n\n                        \"BIGINT\" | \"INT8\" => Value::BigInt(\n                            row.try_get(c.ordinal()).expect(\"Failed to get big integer\"),\n                        ),\n\n                        \"REAL\" => {\n                            Value::Double(row.try_get(c.ordinal()).expect(\"Failed to get double\"))\n                        }\n\n                        \"TEXT\" => Value::String(\n                            row.try_get::<Option<String>, _>(c.ordinal())\n                                .expect(\"Failed to get string\")\n                                .map(Box::new),","sourceCodeStart":397,"sourceCodeEnd":433,"githubUrl":"https://github.com/SeaQL/sea-orm/blob/e29bcd1b417c41a553b386fe94511d7c64a1c8ec/sea-orm-sync/src/driver/sqlx_sqlite.rs#L397-L433","documentation":"Panic in sea-orm-sync's SQLite driver when a column whose type_info name is \"BOOLEAN\" cannot be decoded into the expected boolean type while constructing a ProxyRow. SQLite stores booleans as integers, so this fires when sqlx reports BOOLEAN but the underlying value is not a valid 0/1 integer (or is NULL where a non-Option bool is expected).","triggerScenarios":"Reading a SQLite BOOLEAN-declared column whose stored value is NULL (try_get into non-Option bool), or whose stored value is something other than 0/1 (e.g. text 'true' or integer 2).","commonSituations":"Booleans inserted by another tool as strings 'true'/'false'; columns declared BOOLEAN but populated with arbitrary integers; NULL values in a NOT-NULL-assumed boolean column during migration from other databases.","solutions":["Sanitize stored values so booleans are exactly 0 or 1 integers (UPDATE col SET col = CASE ... )","Make the column NOT NULL with a DEFAULT 0 to eliminate NULL decodes","Check with SELECT typeof(col), col to find offending values before re-querying via ProxyRow","Replace .expect with error propagation and fall back to Value::Int for non-boolean values"],"exampleFix":"// before\n\"BOOLEAN\" => {\n    Value::Bool(row.try_get(c.ordinal()).expect(\"Failed to get boolean\"))\n}\n// after\n\"BOOLEAN\" => {\n    Value::Bool(row.try_get::<Option<bool>, _>(c.ordinal())\n        .expect(\"Failed to get boolean\")\n        .unwrap_or(false))\n}","handlingStrategy":"validation","validationCode":"// Ensure SQLite boolean columns hold only 0/1 integers:\n// SELECT typeof(col), col FROM t WHERE col NOT IN (0, 1) OR col IS NULL;","typeGuard":"fn is_valid_bool_storage(v: Option<i64>) -> bool { matches!(v, Some(0) | Some(1)) }","tryCatchPattern":"let row = std::panic::catch_unwind(|| proxy_query(db)).unwrap_or_else(|_| fallback_row());","preventionTips":["Store booleans strictly as 0/1 integers","Add NOT NULL DEFAULT 0 to boolean columns","Never insert 'true'/'false' strings via raw SQL","Audit legacy rows with typeof() before reading via ProxyRow"],"tags":["rust","sqlx","sqlite","boolean","type-conversion","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"}