{"record":{"id":"50b503866bf3f6cf","repo":"diesel-rs/diesel","slug":"unexpected-oid-when-name-is-present-help-hel","errorCode":null,"errorMessage":"unexpected `oid` when `name` is present\nhelp: {help}","messagePattern":"unexpected `oid` when `name` is present\nhelp: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"diesel_attribute_parser/src/parsers/postgres_type.rs","lineNumber":77,"sourceCode":"        Self::validate_and_build(input, oid, array_oid, name, schema)\n    }\n}\n\nimpl PostgresType {\n    pub fn validate_and_build(\n        input: ParseStream,\n        oid: Option<(Ident, LitInt)>,\n        array_oid: Option<(Ident, LitInt)>,\n        name: Option<(Ident, LitStr)>,\n        schema: Option<(Ident, LitStr)>,\n    ) -> Result<Self> {\n        let help = format!(\n            \"the correct format looks like either `#[diesel({POSTGRES_TYPE_NOTE})]` or `#[diesel({POSTGRES_TYPE_NOTE_ID})]`\"\n        );\n\n        if let Some((_, name)) = name {\n            if let Some((oid, _)) = oid {\n                Err(syn::Error::new(\n                    oid.span(),\n                    format!(\"unexpected `oid` when `name` is present\\nhelp: {help}\"),\n                ))\n            } else if let Some((array_oid, _)) = array_oid {\n                Err(syn::Error::new(\n                    array_oid.span(),\n                    format!(\"unexpected `array_oid` when `name` is present\\nhelp: {help}\"),\n                ))\n            } else {\n                Ok(PostgresType::Lookup(name, schema.map(|s| s.1)))\n            }\n        } else if let Some((schema, lit)) = schema {\n            Err(syn::Error::new(\n                schema.span(),\n                format!(\n                    \"expected `name` to be also present\\n\\\n                     help: make sure `name` is present, `#[diesel(postgres_type(name = \\\"...\\\", schema = \\\"{}\\\"))]`\",\n                    lit.value()","sourceCodeStart":59,"sourceCodeEnd":95,"githubUrl":"https://github.com/diesel-rs/diesel/blob/6fa6ed01b24b24248ab2a611698d0a7c6a2e9120/diesel_attribute_parser/src/parsers/postgres_type.rs#L59-L95","documentation":"Compile-time error validating #[diesel(postgres_type(...))] arguments. In diesel 2.x a type can be identified either by `oid`/`array_oid` or by `name`/`schema`, but not both; this guard fires when `name = \"...\"` is present together with `oid = ...`, since the two lookup modes are mutually exclusive. Fix: remove `oid` (and `array_oid`) when using the name-based lookup, or remove `name`.","triggerScenarios":"Thrown at diesel_attribute_parser/src/parsers/postgres_type.rs:77 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Remove `oid` and keep `name` for lookup by name","Drop `name` and provide `oid`/`array_oid` instead"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"6fa6ed01b24b24248ab2a611698d0a7c6a2e9120","analyzedAt":"2026-09-07T01:50:13.074Z","contentChangedAt":"2026-09-07T01:50:13.074Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}