diesel-rs/diesel · error · syn::Error
Expected `require_order` but got
Error message
Expected `require_order` but got `{ident}` What it means
Inside `#[sql_function]`, the `parse_require_order` helper only accepts the key `require_order = <bool>`. Any other identifier passed where `require_order` is expected produces this error naming what was actually found.
Solutions
- Write the option exactly as `require_order = true` (or `= false`)
- Fix any misspelling of `require_order`
- Remove the extraneous token if it was not intended as an option
Example fix
// before #[sql_function(require_ord = true)] // after #[sql_function(require_order = true)]
Defensive patterns
Strategy: validation
Validate before calling
fn is_require_order_key(key: &str) -> bool { key == "require_order" } Type guard
fn is_require_order_key(key: &str) -> bool { key == "require_order" } Prevention
- Spell the option exactly `require_order` and always provide `= true` or `= false`
- Provide a boolean literal, not an expression
- Keep options in the documented order inside the attribute
When it happens
Trigger: Calling the attr parser with an identifier other than `require_order` where the macro expects it — e.g. `require_ord = true`, `ordering = true`, or passing a key in the wrong position of the attribute list.
Common situations: Typos (`require_order` misspelled); assuming other ordering-related options exist; mixing option order so a value lands where a key is expected.
Understand the failure class
Background: "unknown output mode", "invalid value for flag", "expects true/false": fixing invalid flag value errors in CLI tools — this error's family across 24 libraries.
Related errors
- expected attribute `name` help: the correct format looks…
- unknown attribute, expected
- expect `skip_zero_argument_variant`
- , the correct format is `#[variadic(last_arguments = 3)]`…
- , the correct format is `#[variadic(3)]
AI-assisted analysis of diesel-rs/diesel@6fa6ed01b2 (2026-09-07).
Data as JSON: /api/errors/0bcf3ff19794bf36.
Report an issue: GitHub.
Appendix: source
Thrown at diesel_derives/src/sql_function.rs:1920
SqlFunctionAttribute::Restriction {
restriction: BackendRestriction::None,
..
} => {
unreachable!("We do not construct that")
}
SqlFunctionAttribute::Other(attribute) => attribute.span(),
}
}
}
fn parse_require_order(input: &syn::parse::ParseBuffer<'_>) -> Result<bool> {
let ident = input.parse::<Ident>()?;
if ident == "require_order" {
let _ = input.parse::<Token![=]>()?;
let value = input.parse::<LitBool>()?;
Ok(value.value)
} else {
Err(syn::Error::new(
ident.span(),
format!("Expected `require_order` but got `{ident}`"),
))
}
}
impl SqlFunctionAttribute {
fn parse_attr(
name: Ident,
input: &syn::parse::ParseBuffer<'_>,
attr: Attribute,
attribute_span: proc_macro2::Span,
) -> Result<AttributeSpanWrapper<Self>> {
// rustc doesn't resolve cfg attrs for us :(
// This is hacky, but mostly for internal use
if name == "cfg_attr" {
let ident = input.parse::<Ident>()?;
if ident != "feature" {View on GitHub (pinned to 6fa6ed01b2)