{"record":{"id":"159c1fa2cc2a26ea","repo":"SeaQL/sea-orm","slug":"failed-to-get-double-159c1f","errorCode":null,"errorMessage":"Failed to get double","messagePattern":"Failed to get double","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sea-orm-sync/src/driver/sqlx_sqlite.rs","lineNumber":427,"sourceCode":"            .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())\n                                .expect(\"Failed to get bytes\")\n                                .map(Box::new),\n                        ),\n\n                        #[cfg(feature = \"with-chrono\")]\n                        \"DATETIME\" => {\n                            use chrono::{DateTime, Utc};\n","sourceCodeStart":409,"sourceCodeEnd":445,"githubUrl":"https://github.com/SeaQL/sea-orm/blob/e29bcd1b417c41a553b386fe94511d7c64a1c8ec/sea-orm-sync/src/driver/sqlx_sqlite.rs#L409-L445","documentation":"Panic when sea-orm-sync's SQLite driver cannot decode a \"REAL\" column into f64 while building a ProxyRow. Because SQLite does not enforce storage types, a REAL-declared column may physically contain text or integer values (or NULL) that sqlx refuses to decode into the expected f64.","triggerScenarios":"Reading a REAL column whose stored value has a non-real storage class (TEXT like '3.14', INTEGER, or NULL decoded into non-Option f64).","commonSituations":"Floats inserted as quoted strings by another tool or ORM; data imported from CSV where numbers stayed text; NULLs in legacy rows; columns repurposed after schema changes.","solutions":["Normalize stored values: UPDATE t SET col = CAST(col AS REAL) WHERE typeof(col) != 'real'","Decode as Option<f64> and treat NULL explicitly instead of non-Option try_get","Enforce value hygiene at insert time by going through typed entity models rather than raw SQL","Propagate the sqlx error with column name context instead of .expect"],"exampleFix":"// before\n\"REAL\" => {\n    Value::Double(row.try_get(c.ordinal()).expect(\"Failed to get double\"))\n}\n// after\n\"REAL\" => {\n    Value::Double(row.try_get::<Option<f64>, _>(c.ordinal())\n        .expect(\"Failed to get double\")\n        .unwrap_or(f64::NAN))  // or propagate with column context\n}","handlingStrategy":"validation","validationCode":"// Verify REAL columns hold real storage class:\n// SELECT typeof(col), count(*) FROM t GROUP BY typeof(col);","typeGuard":"fn is_real_storage(type_of: &str) -> bool { type_of == \"real\" }","tryCatchPattern":"let row = std::panic::catch_unwind(|| proxy_query(db)).unwrap_or_else(|_| fallback_row());","preventionTips":["CAST non-real values to REAL after CSV/DB imports","Insert floats via typed entity fields, not quoted raw SQL strings","Declare columns REAL and add NOT NULL where possible","Audit storage classes before ProxyRow reads"],"tags":["rust","sqlx","sqlite","float","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"}