{"record":{"id":"082b479b0f2ab0de","repo":"SeaQL/sea-orm","slug":"failed-to-get-float-082b47","errorCode":null,"errorMessage":"Failed to get float","messagePattern":"Failed to get float","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sea-orm-sync/src/driver/sqlx_postgres.rs","lineNumber":510,"sourceCode":"                        \"BIGINT\" | \"BIGSERIAL\" | \"INT8\" => Value::BigInt(\n                            row.try_get(c.ordinal()).expect(\"Failed to get big integer\"),\n                        ),\n                        #[cfg(feature = \"postgres-array\")]\n                        \"BIGINT[]\" | \"BIGSERIAL[]\" | \"INT8[]\" => Value::Array(\n                            sea_query::ArrayType::BigInt,\n                            row.try_get::<Option<Vec<i64>>, _>(c.ordinal())\n                                .expect(\"Failed to get big integer array\")\n                                .map(|vals: Vec<i64>| {\n                                    Box::new(\n                                        vals.into_iter()\n                                            .map(|val| Value::BigInt(Some(val)))\n                                            .collect(),\n                                    )\n                                }),\n                        ),\n\n                        \"FLOAT4\" | \"REAL\" => {\n                            Value::Float(row.try_get(c.ordinal()).expect(\"Failed to get float\"))\n                        }\n                        #[cfg(feature = \"postgres-array\")]\n                        \"FLOAT4[]\" | \"REAL[]\" => Value::Array(\n                            sea_query::ArrayType::Float,\n                            row.try_get::<Option<Vec<f32>>, _>(c.ordinal())\n                                .expect(\"Failed to get float array\")\n                                .map(|vals| {\n                                    Box::new(\n                                        vals.into_iter()\n                                            .map(|val| Value::Float(Some(val)))\n                                            .collect(),\n                                    )\n                                }),\n                        ),\n\n                        \"FLOAT8\" | \"DOUBLE PRECISION\" => {\n                            Value::Double(row.try_get(c.ordinal()).expect(\"Failed to get double\"))\n                        }","sourceCodeStart":492,"sourceCodeEnd":528,"githubUrl":"https://github.com/SeaQL/sea-orm/blob/e29bcd1b417c41a553b386fe94511d7c64a1c8ec/sea-orm-sync/src/driver/sqlx_postgres.rs#L492-L528","documentation":"This panic comes from an `.expect(\"Failed to get float\")` inside `ProxyRow`, where SeaORM decodes a Postgres column typed FLOAT4/REAL via sqlx `row.try_get::<f32>`. It fires when sqlx cannot decode the raw value into the expected `Option<f32>` shape -- most often because the actual column type at runtime does not match the declared type the driver matched on, so the wire-format type OID differs from what sqlx expects. SeaORM uses `expect` rather than `Result` here, so the failure aborts the whole query instead of returning an error.","triggerScenarios":"Calling any SeaORM query (find/load/raw) whose result set includes a Postgres REAL/FLOAT4 column whose underlying value cannot be decoded as f32; typically after the column's actual type was altered (e.g. to DOUBLE PRECISION or NUMERIC) while the schema cache still reports REAL, or a custom domain/cast type reports type name REAL but has a different OID.","commonSituations":"Schema drift: `ALTER TABLE ... ALTER COLUMN ... TYPE DOUBLE PRECISION` run against a deployed DB while entity definitions still say REAL. Using Postgres extensions or domains over float types that sqlx cannot decode directly. Reading via a view whose column type differs from the entity. Mismatched SeaORM/sqlx minor versions with changed type-OID handling.","solutions":["Verify the actual column type in Postgres (`\\d table` or information_schema.columns) matches REAL/FLOAT4; ALTER the column or update the entity to a compatible type and re-run.","Ensure the SeaORM and sqlx Postgres versions are aligned and regenerated (`cargo update` together) so type OIDs match.","Cast explicitly in raw queries: `SELECT mycol::REAL AS mycol` so the returned type matches the expected f32 decode.","If the column can be NULL-typed or is a domain type, change the model to a type SeaORM maps natively (e.g. Double) or store as TEXT and parse manually."],"exampleFix":"// before: entity expects REAL but DB column is DOUBLE PRECISION\npub price: f32,\n\n// after: align entity type with actual column type\npub price: f64,","handlingStrategy":"validation","validationCode":"// Verify the column type before querying\nlet row: (String,) = sqlx::query_as(\n    \"SELECT data_type FROM information_schema.columns WHERE table_name = $1 AND column_name = $2\"\n).bind(\"my_table\").bind(\"price\").fetch_one(&db).await?;\nassert!(matches!(row.0.as_str(), \"real\"), \"price must be REAL/FLOAT4, got {}\", row.0);","typeGuard":"fn as_f32(v: &sea_orm::Value) -> Option<f32> {\n    match v {\n        sea_orm::Value::Float(x) => *x,\n        _ => None,\n    }\n}","tryCatchPattern":null,"preventionTips":["Keep entity field types synchronized with the database schema; run migrations through SeaORM so drift cannot happen silently.","After any manual ALTER TABLE, regenerate/verify entity definitions before deploying queries.","Pin sea-orm and sqlx to compatible versions and upgrade them together.","Use explicit casts (::REAL) in raw SQL when column types are uncertain."],"tags":["postgres","sqlx","type-mismatch","panic","decode"],"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"}