Skip to main content

Dialect

Trait Dialect 

Source
pub trait Dialect: Send + Sync {
    // Required methods
    fn capabilities(&self) -> BackendCapabilities;
    fn write_placeholder(&self, out: &mut String, index: usize);
    fn cast_type(&self, ty: SqlType) -> &'static str;

    // Provided methods
    fn write_ident(&self, out: &mut String, ident: &str) { ... }
    fn offset_requires_limit(&self) -> bool { ... }
    fn unbounded_limit(&self) -> &'static str { ... }
    fn like_escape_literal(&self) -> &'static str { ... }
    fn default_values_sql(&self) -> &'static str { ... }
    fn supports_aggregate_filter(&self) -> bool { ... }
    fn evaluates_assignments_in_order(&self) -> bool { ... }
}
Expand description

Differences between SQL flavours that the compiler needs to know about.

Required Methods§

Source

fn capabilities(&self) -> BackendCapabilities

Declared capabilities; the compiler rejects plans that exceed them.

Source

fn write_placeholder(&self, out: &mut String, index: usize)

Write the placeholder for the index-th (1-based) bind parameter.

Source

fn cast_type(&self, ty: SqlType) -> &'static str

Type name used in CAST(.. AS <name>).

Provided Methods§

Source

fn write_ident(&self, out: &mut String, ident: &str)

Write a quoted identifier. Embedded quote characters are doubled.

Source

fn offset_requires_limit(&self) -> bool

Whether OFFSET requires a preceding LIMIT.

Source

fn unbounded_limit(&self) -> &'static str

The LIMIT written before a bare OFFSET when offset_requires_limit is set.

Source

fn like_escape_literal(&self) -> &'static str

The SQL string literal used as the LIKE .. ESCAPE character (one backslash).

Source

fn default_values_sql(&self) -> &'static str

The tail of an INSERT INTO t that stores one row of defaults.

Source

fn supports_aggregate_filter(&self) -> bool

Whether aggregates accept FILTER (WHERE ..). When not, the compiler rewrites AGG(x) FILTER (WHERE f) as AGG(CASE WHEN f THEN x END).

Source

fn evaluates_assignments_in_order(&self) -> bool

Whether UPDATE .. SET a = .., b = .. evaluates the assignments left to right, so a later right-hand side sees the new value of an earlier column (standard SQL reads the old values). The compiler then reorders assignments to keep the standard meaning.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§