diesel-rs/diesel · error
unexpected `array_oid` when `name` is present help
Error message
unexpected `array_oid` when `name` is present
help: {help} What it means
Compile-time error validating #[diesel(postgres_type(...))] arguments. Name-based lookup and array_oid-based lookup are mutually exclusive; this guard fires when `name = "..."` is supplied together with `array_oid = ...` in the same attribute. Fix: drop `array_oid` when identifying the type by `name`, or drop `name` to use the oid form.
Solutions
- Remove `array_oid` and keep `name` for lookup by name
- Drop `name` and provide `oid`/`array_oid` instead
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at diesel_attribute_parser/src/parsers/postgres_type.rs:82 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/16e1ad579ed2ca33.
Report an issue: GitHub.
Appendix: source
Thrown at diesel_attribute_parser/src/parsers/postgres_type.rs:82
pub fn validate_and_build(
input: ParseStream,
oid: Option<(Ident, LitInt)>,
array_oid: Option<(Ident, LitInt)>,
name: Option<(Ident, LitStr)>,
schema: Option<(Ident, LitStr)>,
) -> Result<Self> {
let help = format!(
"the correct format looks like either `#[diesel({POSTGRES_TYPE_NOTE})]` or `#[diesel({POSTGRES_TYPE_NOTE_ID})]`"
);
if let Some((_, name)) = name {
if let Some((oid, _)) = oid {
Err(syn::Error::new(
oid.span(),
format!("unexpected `oid` when `name` is present\nhelp: {help}"),
))
} else if let Some((array_oid, _)) = array_oid {
Err(syn::Error::new(
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 {View on GitHub (pinned to 6fa6ed01b2)