SeaQL/sea-orm · error
Failed to get oid array
Error message
Failed to get oid array
What it means
ProxyRow maps Postgres OID[] columns to a Vec<i64> via row.try_get::<Option<Vec<i64>>, _> and .expect("Failed to get oid array"), panicking on any sqlx decode failure. This means the column is reported as an OID array but its elements could not be decoded as i64 — typically an element-type mismatch (u32 OIDs, bigint domains, or a non-array value in an array-typed column).
Source
Thrown at src/driver/sqlx_postgres.rs:643
row.try_get::<Option<Vec<rust_decimal::Decimal>>, _>(c.ordinal())
.expect("Failed to get numeric array")
.map(|vals| {
Box::new(
vals.into_iter()
.map(|val| Value::Decimal(Some(val)))
.collect(),
)
}),
),
"OID" => {
Value::BigInt(row.try_get(c.ordinal()).expect("Failed to get oid"))
}
#[cfg(feature = "postgres-array")]
"OID[]" => Value::Array(
sea_query::ArrayType::BigInt,
row.try_get::<Option<Vec<i64>>, _>(c.ordinal())
.expect("Failed to get oid array")
.map(|vals| {
Box::new(
vals.into_iter()
.map(|val| Value::BigInt(Some(val)))
.collect(),
)
}),
),
#[cfg(feature = "with-json")]
"JSON" | "JSONB" => Value::Json(
row.try_get::<Option<serde_json::Value>, _>(c.ordinal())
.expect("Failed to get json")
.map(Box::new),
),
#[cfg(all(
feature = "with-json",
any(feature = "json-array", feature = "postgres-array")View on GitHub (pinned to e29bcd1b41)
Solutions
- Verify the real column type with information_schema/psql \d and confirm it is a genuine oid[] (udt_name like _oid).
- Cast in SQL to a plain array: SELECT my_col::bigint[] AS my_col.
- Align sqlx and sea-orm versions so array decode expectations match.
- In driver code, map the sqlx error to DbErr instead of .expect so the offending column/ordinal is reported.
Example fix
// before
.expect("Failed to get oid array")
// after
.map_err(|e| DbErr::TryIntoError { value_type: "oid[]".into(), source: e.into() })? Defensive patterns
Strategy: validation
Validate before calling
let udt: (String,) = sqlx::query_as(
"SELECT udt_name FROM information_schema.columns WHERE table_name=$1 AND column_name=$2",
)
.bind("my_table").bind("roles").fetch_one(&pool).await?;
assert_eq!(udt.0, "_oid", "expected real oid[] column"); Type guard
fn is_oid_array(udt_name: &str) -> bool { udt_name == "_oid" } Prevention
- Ensure catalog-style array columns are true arrays, not oid2vector/commas-in-text
- Cast to ::bigint[] in SQL when element types are uncertain
- Avoid custom domains over oid[] in schemas read through the proxy
- Pin a single sqlx version to keep array codecs consistent
When it happens
Trigger: A query through the postgres Proxy driver selecting a column whose type name is "OID[]" where the underlying value is not an array of 64-bit OIDs, e.g. it is a scalar oid (comma-separated text), a domain over oid[], or sqlx's Vec<u32> codec is what actually matches.
Common situations: Reading catalog/ACL-style columns (e.g. pg_policy.polroles is oid2vector, not a plain array); migrations that changed an array column's element type; version drift between sqlx and sea-orm changing array codecs.
Understand the failure class
Background: Type mismatch errors: IllegalArgumentException, TypeError and type guards across 150 open-source libraries — this error's family across 150 libraries.
Related errors
- Failed to get uuid array
- Failed to get float array
- Failed to get double array
- Failed to get string array
- Failed to get uuid
AI-assisted analysis of SeaQL/sea-orm@e29bcd1b41 (2026-09-10).
Data as JSON: /api/errors/5fbac5d2d5a9e8e3.
Report an issue: GitHub.