Skip to main content

Dialect

Trait Dialect 

Source
pub trait Dialect:
    Sized
    + Send
    + Sync
    + 'static {
    // Required methods
    fn quote_char() -> char;
    fn write_placeholder(out: &mut String, n: usize);
    fn supports_returning() -> bool;

    // Provided methods
    fn upsert_style() -> UpsertStyle { ... }
    fn supports_distinct_on() -> bool { ... }
    fn ilike_is_native() -> bool { ... }
}
Expand description

Compile-time description of a SQL dialect.

Required Methods§

Source

fn quote_char() -> char

The identifier quote character (e.g. backtick for MySQL, " for ANSI).

Source

fn write_placeholder(out: &mut String, n: usize)

Write the bind placeholder for the n-th parameter (1-based) into out.

Dialects with positional placeholders (?) ignore n.

Source

fn supports_returning() -> bool

Whether this dialect supports the RETURNING clause.

Provided Methods§

Source

fn upsert_style() -> UpsertStyle

How this dialect expresses an upsert. Defaults to UpsertStyle::OnConflict (Postgres / SQLite); MySQL overrides to UpsertStyle::OnDuplicateKey.

Source

fn supports_distinct_on() -> bool

Whether this dialect supports SELECT DISTINCT ON (cols). Defaults to false; only Postgres overrides to true. Compiling a distinct_on query against a dialect that returns false panics.

Source

fn ilike_is_native() -> bool

Whether this dialect has a native case-insensitive ILIKE operator. Defaults to false; only Postgres overrides to true. When false, where_ilike is compiled as LOWER(col) LIKE LOWER(?).

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§