Skip to main content

SQLParam

Trait SQLParam 

Source
pub trait SQLParam: Clone + Debug {
    type DialectMarker: DialectTypes;

    const DIALECT: Dialect;

    // Provided method
    fn pagination_param(value: usize) -> Option<Self> { ... }
}
Expand description

A marker trait for types that can be used as SQL parameters.

This trait is used as a bound on the parameter type in SQL fragments. It ensures type safety when building SQL queries with parameters.

Required Associated Constants§

Source

const DIALECT: Dialect

The SQL dialect for this parameter type

Required Associated Types§

Source

type DialectMarker: DialectTypes

Type-level dialect marker for compile-time dispatch.

Used by crate::row::SQLTypeToRust to select dialect-specific type mappings and by crate::dialect::DialectTypes to resolve conceptual SQL types to dialect-native markers.

Provided Methods§

Source

fn pagination_param(value: usize) -> Option<Self>

Converts a numeric LIMIT/OFFSET value into a bindable parameter.

Dialects that return Some render .limit(n) / .offset(n) as a bound parameter instead of a numeric literal, keeping the generated SQL text stable across pagination values so statement caches can hit. The default (None) keeps the numeric-literal rendering.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§