{"record":{"id":"5ec044372f965890","repo":"SeaQL/sea-orm","slug":"failed-to-get-big-integer-array","errorCode":null,"errorMessage":"Failed to get big integer array","messagePattern":"Failed to get big integer array","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sea-orm-sync/src/driver/sqlx_postgres.rs","lineNumber":499,"sourceCode":"                        \"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                        }\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| {","sourceCodeStart":481,"sourceCodeEnd":517,"githubUrl":"https://github.com/SeaQL/sea-orm/blob/e29bcd1b417c41a553b386fe94511d7c64a1c8ec/sea-orm-sync/src/driver/sqlx_postgres.rs#L481-L517","documentation":"Panic while decoding a Postgres bigint array column (BIGINT[]/BIGSERIAL[]/INT8[]) in ProxyRow conversion: `row.try_get::<Option<Vec<i64>>, _>(ordinal).expect(\"Failed to get big integer array\")`. A NULL array is tolerated by the Option target, so failure means an element could not be decoded as i64 — typically NULL elements inside the array (decode requires `Vec<Option<i64>>`) — or the runtime data is not an i64 array despite the reported type name.","triggerScenarios":"Selecting an int8 array containing NULL elements (e.g. `array_agg(bigint_col)` over rows with NULLs); array-of-DOMAIN over bigint; a view or custom type reporting BIGINT[] whose elements are not i64-decodable.","commonSituations":"Aggregating nullable bigint id columns into arrays; unnest/merge pipelines producing sparse arrays; schema migrations altering element types while reported names lag; Postgres DOMAIN arrays over bigint.","solutions":["Decode elements as Option: `row.try_get::<Option<Vec<Option<i64>>>, _>(c.ordinal())` and map None elements explicitly.","Strip NULLs in SQL: `array_remove(col, NULL::bigint)` or `COALESCE(array_agg(x), ARRAY[]::bigint[])`.","Cast to plain bigint[] (`col::bigint[]`) to bypass DOMAIN arrays.","Verify element type with `pg_typeof` and fix schema or query accordingly.","Enforce NOT NULL on the source column when the model expects plain i64 elements."],"exampleFix":"// before (panics on NULL elements)\n\"BIGINT[]\" | \"BIGSERIAL[]\" | \"INT8[]\" => Value::Array(ArrayType::BigInt,\n    row.try_get::<Option<Vec<i64>>, _>(c.ordinal()).expect(\"Failed to get big integer array\")...),\n// after (SQL-side guard)\n// SELECT array_remove(col, NULL::bigint) AS col FROM t;\n\"BIGINT[]\" | \"BIGSERIAL[]\" | \"INT8[]\" => Value::Array(ArrayType::BigInt,\n    row.try_get::<Option<Vec<i64>>, _>(c.ordinal()).expect(\"Failed to get big integer array\")...),","handlingStrategy":"try-catch","validationCode":"// SELECT bool_and(e IS NOT NULL) FROM unnest(col::bigint[]) AS e;\n// or in SQL: SELECT array_remove(col, NULL::bigint) AS col FROM t;","typeGuard":"fn as_i64_array(row: &ProxyRow, col: &str) -> Option<Vec<i64>> {\n    match row.value(col) {\n        Some(Value::Array(ArrayType::BigInt, vals)) => Some(\n            vals.iter().filter_map(|v| match v {\n                Value::BigInt(Some(x)) => Some(*x),\n                _ => None,\n            }).collect(),\n        ),\n        _ => None,\n    }\n}","tryCatchPattern":"let result = std::panic::catch_unwind(|| proxy_row_get_i64_array(&row, \"ids\"));\nmatch result {\n    Ok(v) => v,\n    Err(_) => Vec::new(), // or re-query with array_remove(col, NULL::bigint)\n}","preventionTips":["array_remove(col, NULL) before reading bigint[] columns from nullable sources.","COALESCE(array_agg(x), ARRAY[]::bigint[]) on aggregations.","Decode element-nullable arrays as Vec<Option<i64>> in custom paths.","Verify element types with pg_typeof/unnest before binding fixed decode targets."],"tags":["postgres","sqlx","array-decode","type-decode","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"}