{"record":{"id":"7433a181703ea3e7","repo":"SeaQL/sea-orm","slug":"failed-to-get-integer-7433a1","errorCode":null,"errorMessage":"Failed to get integer","messagePattern":"Failed to get integer","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sea-orm-sync/src/driver/sqlx_sqlite.rs","lineNumber":419,"sourceCode":"pub(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),\n                        ),\n\n                        \"BLOB\" => Value::Bytes(\n                            row.try_get::<Option<Vec<u8>>, _>(c.ordinal())","sourceCodeStart":401,"sourceCodeEnd":437,"githubUrl":"https://github.com/SeaQL/sea-orm/blob/e29bcd1b417c41a553b386fe94511d7c64a1c8ec/sea-orm-sync/src/driver/sqlx_sqlite.rs#L401-L437","documentation":"Panic when sea-orm-sync's SQLite driver cannot decode a column reported as \"INTEGER\" into an i32 while building a ProxyRow. SQLite integers are 64-bit, so this commonly fires when the stored value exceeds i32 range or is NULL where a non-Option i32 is expected.","triggerScenarios":"Reading an INTEGER column whose value is > i32::MAX or < i32::MIN (try_get::<i32> fails with a range error), or a NULL value decoded into a non-Option type.","commonSituations":"SQLite tables created with 64-bit values (e.g. timestamps, snowflake IDs) read through a schema that maps INTEGER to i32; data imported from Postgres BIGINT columns; NULLs in legacy rows.","solutions":["Change the column mapping so INTEGER values decode as i64 (BigInt) instead of i32, or widen the entity field to i64","Fix out-of-range rows (SELECT * FROM t WHERE col > 2147483647 OR col < -2147483648)","Add NOT NULL DEFAULT constraints to avoid NULL decode failures","Propagate the sqlx error instead of .expect so callers can handle per-row failures"],"exampleFix":"// before\n\"INTEGER\" => {\n    Value::Int(row.try_get(c.ordinal()).expect(\"Failed to get integer\"))\n}\n// after\n\"INTEGER\" => match row.try_get::<i64, _>(c.ordinal()) {\n    Ok(v) if v >= i32::MIN as i64 && v <= i32::MAX as i64 => Value::Int(v as i32),\n    Ok(v) => Value::BigInt(v),\n    Err(e) => panic!(\"Failed to get integer for col {}: {}\", c.name(), e),\n}","handlingStrategy":"validation","validationCode":"// Detect out-of-i32-range INTEGER values before decoding:\n// SELECT * FROM t WHERE col > 2147483647 OR col < -2147483648 OR col IS NULL;","typeGuard":"fn fits_i32(v: i64) -> bool { v >= i32::MIN as i64 && v <= i32::MAX as i64 }","tryCatchPattern":"let row = std::panic::catch_unwind(|| proxy_query(db)).unwrap_or_else(|_| fallback_row());","preventionTips":["Use i64/BigInt entity fields for SQLite INTEGER columns","Migrate large values (ids, timestamps) out of i32-mapped columns","Add NOT NULL DEFAULT constraints","Check imported data for values beyond i32 range"],"tags":["rust","sqlx","sqlite","integer","overflow","type-conversion","panic"],"backgroundTag":"value-out-of-range","analyzedSha":"e29bcd1b417c41a553b386fe94511d7c64a1c8ec","analyzedAt":"2026-09-10T11:31:52.468Z","contentChangedAt":"2026-09-10T11:31:52.468Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}