diesel-rs/diesel · error

expected `name` to be also present help: make sure `name`…

Error message

expected `name` to be also present
help: make sure `name` is present, `#[diesel(postgres_type(name = "...", schema = "{}"))]`

What it means

Compile-time error validating #[diesel(postgres_type(...))] arguments. `schema = "..."` is only meaningful as a qualifier for a name-based lookup; this guard fires when `schema` is given without a `name` attribute in the same attribute list. Fix: add `name = "..."` alongside `schema`, or remove the schema argument.

Solutions

  1. Add a `name = "..."` entry alongside `schema`
  2. Remove `schema` if lookup by name is not intended
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at diesel_attribute_parser/src/parsers/postgres_type.rs:90 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/ce7e6240dd5823a6. Report an issue: GitHub.

Appendix: source

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

            "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 {
            Err(syn::Error::new(
                input.span(),
                format!(
                    "expected `oid` and `array_oid` attribute or `name` attribute\nhelp: {help}"
                ),
            ))
        }
    }

View on GitHub (pinned to 6fa6ed01b2)