{"record":{"id":"1cf868fa3ccc917e","repo":"SeaQL/sea-orm","slug":"failed-to-get-big-integer-1cf868","errorCode":null,"errorMessage":"Failed to get big integer","messagePattern":"Failed to get big integer","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sea-orm-sync/src/driver/sqlx_postgres.rs","lineNumber":493,"sourceCode":"                        ),\n\n                        \"INT\" | \"SERIAL\" | \"INT4\" => {\n                            Value::Int(row.try_get(c.ordinal()).expect(\"Failed to get integer\"))\n                        }\n                        #[cfg(feature = \"postgres-array\")]\n                        \"INT[]\" | \"SERIAL[]\" | \"INT4[]\" => Value::Array(\n                            sea_query::ArrayType::Int,\n                            row.try_get::<Option<Vec<i32>>, _>(c.ordinal())\n                                .expect(\"Failed to get integer array\")\n                                .map(|vals: Vec<i32>| {\n                                    Box::new(\n                                        vals.into_iter().map(|val| Value::Int(Some(val))).collect(),\n                                    )\n                                }),\n                        ),\n\n                        \"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                        }","sourceCodeStart":475,"sourceCodeEnd":511,"githubUrl":"https://github.com/SeaQL/sea-orm/blob/e29bcd1b417c41a553b386fe94511d7c64a1c8ec/sea-orm-sync/src/driver/sqlx_postgres.rs#L475-L511","documentation":"Panic while converting a Postgres row to ProxyRow: a column matched as BIGINT/BIGSERIAL/INT8 is decoded with `row.try_get::<i64>(ordinal).expect(\"Failed to get big integer\")`. `try_get` fails when the value is NULL (scalar i64 target rejects NULL, `UnexpectedNullError`) or the value cannot decode as i64 despite the reported type name (e.g. a DOMAIN over bigint or a shadowed type).","triggerScenarios":"Reading a nullable int8 column through ProxyRow (outer-join misses, nullable views); querying a Postgres DOMAIN over bigint; bigserial id columns appearing as NULL in a LEFT JOIN result.","commonSituations":"Nullable FK columns of type bigint read via raw/ProxyRow queries; views projecting nullable values over NOT NULL base columns; DOMAIN types over bigint; count()/aggregate columns cast to bigint that come back NULL in empty-set aggregations (`COUNT` returns 0, but `SUM`/`MAX` return NULL).","solutions":["Decode as Option: `row.try_get::<Option<i64>, _>(c.ordinal())` and map to `Value::BigInt(opt)`.","COALESCE in SQL (`COALESCE(SUM(x), 0)`) when NULL aggregates should default to 0.","ALTER TABLE ... SET NOT NULL (with DEFAULT) on columns guaranteed non-null.","Cast away DOMAINs (`col::bigint`) so the decode target matches i64.","Check `pg_typeof(col)`/search_path for shadowed types and correct schema or the type-name match."],"exampleFix":"// before (panics on NULL)\n\"BIGINT\" | \"BIGSERIAL\" | \"INT8\" => Value::BigInt(\n    row.try_get(c.ordinal()).expect(\"Failed to get big integer\"),\n),\n// after (NULL-safe)\n\"BIGINT\" | \"BIGSERIAL\" | \"INT8\" => Value::BigInt(\n    row.try_get::<Option<i64>, _>(c.ordinal())\n        .expect(\"Failed to get big integer\")\n        .unwrap_or_default(),\n),","handlingStrategy":"try-catch","validationCode":"// SELECT column_name, is_nullable, data_type FROM information_schema.columns\n//   WHERE table_name = 't' AND data_type = 'bigint';\n// NULL from aggregates: SELECT COALESCE(SUM(x), 0)::bigint FROM t;","typeGuard":"fn as_i64(row: &ProxyRow, col: &str) -> Option<i64> {\n    match row.value(col) {\n        Some(Value::BigInt(v)) => v,\n        _ => None,\n    }\n}","tryCatchPattern":"let result = std::panic::catch_unwind(|| proxy_row_get_i64(&row, \"total\"));\nmatch result {\n    Ok(v) => v,\n    Err(_) => treat_as_null_or_default(), // SUM/MAX over empty sets return NULL\n}","preventionTips":["Wrap nullable aggregates (SUM/MAX/AVG) in COALESCE so bigint columns never come back NULL.","Map nullable bigint FK columns to Option<i64> in raw queries.","SET NOT NULL + DEFAULT on bigint columns the model guarantees.","Cast DOMAINs over bigint to base bigint in queries."],"tags":["postgres","sqlx","type-decode","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"}