Skip to main content

SQLParam

Trait SQLParam 

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

    const DIALECT: Dialect;

    // Provided methods
    fn pagination_param(value: usize) -> Option<Self> { ... }
    fn write_literal(&self, buf: &mut String) -> bool { ... }
}
Expand description

A driver’s value type: what bound parameters hold (SQLiteValue, PostgresValue, MySQLValue, …).

Every SQL fragment is generic over one, and it fixes the dialect: placeholder syntax, identifier quoting, and type mappings.

Required Associated Constants§

Source

const DIALECT: Dialect

The dialect, at runtime.

Required Associated Types§

Source

type DialectMarker: DialectTypes

The dialect, as a type (SQLiteDialect, PostgresDialect or MySQLDialect).

Selects type mappings (SQLTypeToRust, DialectTypes) and dialect-only features (DialectSupports).

Provided Methods§

Source

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

Converts a LIMIT/OFFSET value into a parameter, or returns None to write it as a literal (the default).

Binding keeps the SQL text the same across pages, so a cached prepared statement can be reused.

Source

fn write_literal(&self, buf: &mut String) -> bool

Appends this value to buf as a SQL literal of this dialect.

Used where a statement cannot take bound parameters, such as the body of a CREATE VIEW. Returns false, having written nothing, when the value has no literal form; the default knows none.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§