SeaQL/sea-orm · error
Failed to get oid
Error message
Failed to get oid
What it means
SeaORM's ProxyRow maps Postgres OID columns by calling row.try_get::<Option<u32/i64>> with .expect("Failed to get oid"), so any sqlx decode error panics with this message. It means the value in an OID-typed column could not be decoded into the expected integer type — usually because the column's actual wire type differs from what sqlx expects for OID, or the sqlx/postgres version uses a different OID representation (u32 vs i64).
Source
Thrown at src/driver/sqlx_postgres.rs:637
feature = "with-rust_decimal",
not(feature = "with-bigdecimal"),
feature = "postgres-array"
))]
"NUMERIC[]" => Value::Array(
sea_query::ArrayType::Decimal,
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())View on GitHub (pinned to e29bcd1b41)
Solutions
- Inspect the actual Postgres column type (SELECT column_name, data_type, udt_name FROM information_schema.columns ...) and make sure it is truly oid/int8-compatible.
- Cast the column in SQL to a supported type: SELECT my_oid_col::bigint AS my_oid_col.
- Align sea-orm and sqlx versions in Cargo.toml so their Postgres OID codecs agree.
- If you maintain the driver code, replace .expect with a mapped error or a fallback Value::BigInt(None) so a decode failure is reported, not panicked.
Example fix
// before
"OID" => Value::BigInt(row.try_get(c.ordinal()).expect("Failed to get oid")),
// after
"OID" => Value::BigInt(row
.try_get::<Option<i64>, _>(c.ordinal())
.map_err(|e| DbErr::TryIntoError { value_type: "oid".into(), source: e.into() })?), Defensive patterns
Strategy: validation
Validate before calling
// Check the real column type before querying through the proxy
let rows: Vec<(String, String)> = sqlx::query_as(
"SELECT column_name, udt_name FROM information_schema.columns \
WHERE table_name = $1 AND udt_name NOT IN ('oid')",
)
.bind("my_table")
.fetch_all(&pool)
.await?;
assert!(rows.is_empty(), "non-oid columns misreported: {:?}", rows); Type guard
fn is_oid_type(udt_name: &str) -> bool { matches!(udt_name, "oid" | "xid") } Prevention
- Cast oid-like columns to bigint in SELECTs that go through the Proxy driver
- Keep sea-orm and sqlx on versions tested together in the same lockfile
- Prefer explicit column types in migrations over domains wrapping oid
- Check information_schema.udt_name before adding columns to proxy queries
When it happens
Trigger: Calling any SeaORM query (Entity::find, raw query through the Proxy driver) that selects a column whose Postgres type name is "OID" when sqlx's try_get on that column returns a type-mismatch or decode error, e.g. the column is a custom domain over oid, or a regenerated driver crate decodes OID as u32 while this code expects the Option<i64> path.
Common situations: Selecting system catalog columns (e.g. pg_class.relfilenode, pg_type.oid) via Proxy; schema drift after a migration changed the column type; mixing sea-orm and sqlx minor versions with incompatible postgres type codec expectations.
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 float
- Failed to get float array
- Failed to get double
- Failed to get double array
- Failed to get string
AI-assisted analysis of SeaQL/sea-orm@e29bcd1b41 (2026-09-10).
Data as JSON: /api/errors/0f968f0a7894db4a.
Report an issue: GitHub.