SeaQL/sea-orm · error
Failed to get oid array
Error message
Failed to get oid array
What it means
This panic is raised when sea-orm cannot decode an OID[] (oid array) column into Option<Vec<i64>> in its Postgres driver. `try_get` fails when the underlying value is not an oid array, an array element type sqlx cannot decode, or the driver/feature setup doesn't match the runtime wire format. The `.expect` escalates the sqlx error to a panic during row conversion.
Source
Thrown at sea-orm-sync/src/driver/sqlx_postgres.rs:630
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
- Cast the array explicitly to bigint[] in SQL: `SELECT proargtypes::bigint[] FROM pg_proc`.
- Verify the element type with `SELECT pg_typeof(col)`; ensure it is `oid[]` and not text[]/bytea[] like `proacl`.
- Update sqlx/sea-orm to versions that support the oid element type in arrays.
- Bypass sea-orm's typed decode for catalog columns and select them as text (`col::text`) if you only need display.
Example fix
// before SELECT proargtypes FROM pg_proc; // after SELECT proargtypes::bigint[] AS proargtypes FROM pg_proc;
Defensive patterns
Strategy: validation
Validate before calling
// Verify the array element type before selecting oid[] columns:
let t = db.query_one(Statement::from_string(
DatabaseBackend::Postgres,
"SELECT format_type(a.atttypid, a.atttypmod) FROM pg_attribute a WHERE a.attrelid = 'pg_proc'::regclass AND a.attname = 'proargtypes'",
)).await?;
// expect "oid[]" Try / catch
// Fall back to a bigint[] cast in a catch_unwind boundary:
let result = std::panic::catch_unwind(std::panic::AssertUnwindSafe(||
db.query_all(Statement::from_string(DatabaseBackend::Postgres, "SELECT proargtypes::bigint[] FROM pg_proc"))
)); Prevention
- Cast oid[] columns to bigint[] in raw SQL for a predictable wire type.
- Distinguish oid[] from bytea[] columns like proacl when introspecting catalogs.
- Enable the postgres-array feature only when actually querying array columns.
- Test catalog queries against your target Postgres version.
When it happens
Trigger: Selecting an oid[] column (e.g. pg_type.oid lists, aclitem-related arrays, `proargtypes`) with `postgres-array` feature enabled when the array element OID is unknown to sqlx, or the column was cast/aliased in SQL so the wire type is text[]/bytea instead of oid[].
Common situations: Catalog-driven tooling reading pg_proc.proargtypes or similar oid vectors; raw SQL casting oid[] to text[] for logging then trying to load it back through the entity; newer Postgres versions introducing types sqlx doesn't know.
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 numeric array
- Failed to get oid
- Failed to get json
- Failed to get json array
- Failed to get ip address
AI-assisted analysis of SeaQL/sea-orm@e29bcd1b41 (2026-09-10).
Data as JSON: /api/errors/2e7d5d0b276651c8.
Report an issue: GitHub.