Skip to main content

DbFunction

Trait DbFunction 

Source
pub trait DbFunction<T>:
    Clone
    + Send
    + Sync
    + 'static {
    // Required method
    fn name(&self, dialect: Dialect) -> Result<Cow<'static, str>, QueryError>;

    // Provided methods
    fn validate(
        &self,
        _dialect: Dialect,
        _arity: usize,
    ) -> Result<(), QueryError> { ... }
    fn supports_window(&self) -> bool { ... }
}
Expand description

Dialect-aware typed SQL function.

Implement this for reusable functions such as unaccent, JSON helpers, or project-specific database functions. The renderer validates the function for the active dialect before writing SQL.

Required Methods§

Source

fn name(&self, dialect: Dialect) -> Result<Cow<'static, str>, QueryError>

Returns the SQL function name for dialect.

Provided Methods§

Source

fn validate(&self, _dialect: Dialect, _arity: usize) -> Result<(), QueryError>

Validates dialect support and argument count.

Source

fn supports_window(&self) -> bool

Whether this function can be rendered with OVER (...).

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§