diesel::prelude

Macro sql_function

Source
sql_function!() { /* proc-macro */ }
Available on crate feature with-deprecated and non-crate feature without-deprecated only.
Expand description

A legacy version of define_sql_function!.

The difference is that it makes the helper type available in a module named the exact same as the function:

sql_function!(fn lower(x: Text) -> Text);

will generate this code:

pub fn lower<X>(x: X) -> lower::HelperType<X> {
    ...
}

pub(crate) mod lower {
    pub type HelperType<X> = ...;
}

This turned out to be an issue for the support of the auto_type feature, which is why define_sql_function! was introduced (and why this is deprecated).

SQL functions declared with this version of the macro will not be usable with #[auto_type] or Selectable select_expression type inference.