{"record":{"id":"69e115258f5c2f17","repo":"SeaQL/sea-orm","slug":"failed-to-get-oid","errorCode":null,"errorMessage":"Failed to get oid","messagePattern":"Failed to get oid","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sea-orm-sync/src/driver/sqlx_postgres.rs","lineNumber":624,"sourceCode":"                            feature = \"with-rust_decimal\",\n                            not(feature = \"with-bigdecimal\"),\n                            feature = \"postgres-array\"\n                        ))]\n                        \"NUMERIC[]\" => Value::Array(\n                            sea_query::ArrayType::Decimal,\n                            row.try_get::<Option<Vec<rust_decimal::Decimal>>, _>(c.ordinal())\n                                .expect(\"Failed to get numeric array\")\n                                .map(|vals| {\n                                    Box::new(\n                                        vals.into_iter()\n                                            .map(|val| Value::Decimal(Some(val)))\n                                            .collect(),\n                                    )\n                                }),\n                        ),\n\n                        \"OID\" => {\n                            Value::BigInt(row.try_get(c.ordinal()).expect(\"Failed to get oid\"))\n                        }\n                        #[cfg(feature = \"postgres-array\")]\n                        \"OID[]\" => Value::Array(\n                            sea_query::ArrayType::BigInt,\n                            row.try_get::<Option<Vec<i64>>, _>(c.ordinal())\n                                .expect(\"Failed to get oid array\")\n                                .map(|vals| {\n                                    Box::new(\n                                        vals.into_iter()\n                                            .map(|val| Value::BigInt(Some(val)))\n                                            .collect(),\n                                    )\n                                }),\n                        ),\n\n                        #[cfg(feature = \"with-json\")]\n                        \"JSON\" | \"JSONB\" => Value::Json(\n                            row.try_get::<Option<serde_json::Value>, _>(c.ordinal())","sourceCodeStart":606,"sourceCodeEnd":642,"githubUrl":"https://github.com/SeaQL/sea-orm/blob/e29bcd1b417c41a553b386fe94511d7c64a1c8ec/sea-orm-sync/src/driver/sqlx_postgres.rs#L606-L642","documentation":"This panic fires when sea-orm's Postgres decoder cannot read an OID-typed column into i64 via `row.try_get`. OIDs in Postgres are unsigned 32-bit values; sea-orm maps them to BigInt. try_get fails if the actual cell is not the expected type (e.g. the query returns text or a regclass rendering), the type OID isn't recognized, or NULL arrives where sqlx's decode path cannot produce the requested Option type. The `.expect` converts the error into a panic.","triggerScenarios":"Selecting an OID column (e.g. from pg_catalog tables like pg_class.oid, pg_type.oid, or a custom `oid` column) through a raw query or entity whose column type string resolves to \"OID\", while sqlx returns a different internal type; casting oid to regclass/text in SQL (`oid::regclass`) changes the returned type and breaks the decoder.","commonSituations":"Introspection queries against Postgres system catalogs; raw SQL where `oid` was cast to text or regclass for readability; schema drift where a column named like an oid is actually integer/text.","solutions":["Inspect the returned type (`SELECT pg_typeof(oid_col)`) and remove SQL casts such as `::regclass` or `::text` on oid columns.","Match your entity/`ColumnDef` type name to the real column type (declare it as integer if the column is int4, not oid).","Keep sea-orm and sqlx versions in sync; a mismatched sqlx version can change OID decoding.","Cast explicitly in SQL to the type you intend: `SELECT oid::bigint FROM pg_class`."],"exampleFix":"// before\nSELECT oid::regclass FROM pg_class WHERE relname = 'users';\n\n// after\nSELECT oid FROM pg_class WHERE relname = 'users';","handlingStrategy":"validation","validationCode":"// Confirm the returned type before decoding as oid:\nlet t = db.query_one(Statement::from_string(\n    DatabaseBackend::Postgres,\n    \"SELECT pg_typeof(oid)::text FROM pg_class LIMIT 1\",\n)).await?;\n// expect \"oid\"; if it says \"text\" or \"regclass\", remove casts in your query.","typeGuard":null,"tryCatchPattern":"// Decode defensively via raw SQL as text first, then parse:\nlet raw = db.query_all(Statement::from_string(\n    DatabaseBackend::Postgres,\n    \"SELECT oid::text FROM pg_class\",\n)).await?;\nlet oids: Vec<i64> = raw.iter().filter_map(|r| r.try_get::<String, _>(0).ok()?.parse().ok()).collect();","preventionTips":["Never cast oid columns to regclass/text in queries fetched through entities.","Check `pg_typeof` output when writing raw catalog queries.","Match your ColumnDef type name to the actual storage type.","Pin sqlx to the version sea-orm was tested against."],"tags":["postgres","type-decoding","panic","oid","sea-orm"],"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"}