diesel-rs/diesel · error

expected `oid` and `array_oid` attribute or `name`…

Error message

expected `oid` and `array_oid` attribute or `name` attribute
help: {help}

What it means

Compile-time error validating #[diesel(postgres_type(...))] arguments. This is the completeness check of validate_and_build: when neither the oid form (`oid`/`array_oid`) nor the name form (`name`, optionally with `schema`) was supplied, the attribute identifies nothing and this fallback error fires with a help line describing both accepted formats. Fix: provide either `name = "..."` or `oid = ...`/`array_oid = ...`.

Solutions

  1. Provide both `oid` and `array_oid`
  2. Provide `name = "..."` for lookup by name
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at diesel_attribute_parser/src/parsers/postgres_type.rs:101 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of diesel-rs/diesel@6fa6ed01b2 (2026-09-07). Data as JSON: /api/errors/99ddd446bf5c4e07. Report an issue: GitHub.

Appendix: source

Thrown at diesel_attribute_parser/src/parsers/postgres_type.rs:101

                    array_oid.span(),
                    format!("unexpected `array_oid` when `name` is present\nhelp: {help}"),
                ))
            } else {
                Ok(PostgresType::Lookup(name, schema.map(|s| s.1)))
            }
        } else if let Some((schema, lit)) = schema {
            Err(syn::Error::new(
                schema.span(),
                format!(
                    "expected `name` to be also present\n\
                     help: make sure `name` is present, `#[diesel(postgres_type(name = \"...\", schema = \"{}\"))]`",
                    lit.value()
                ),
            ))
        } else if let (Some((_, oid)), Some((_, array_oid))) = (oid, array_oid) {
            Ok(PostgresType::Fixed(oid, array_oid))
        } else {
            Err(syn::Error::new(
                input.span(),
                format!(
                    "expected `oid` and `array_oid` attribute or `name` attribute\nhelp: {help}"
                ),
            ))
        }
    }
}

View on GitHub (pinned to 6fa6ed01b2)