Skip to main content

Dialect

Trait Dialect 

Source
pub trait Dialect:
    'static
    + Copy
    + Default
    + Sealed {
    const IDENTIFIER_QUOTE: char;
    const CAST_BIGINT: &'static str = "BIGINT";
    const CAST_DOUBLE: &'static str = "DOUBLE PRECISION";
    const PARENTHESIZED_SET_OP_BRANCHES: bool = true;
    const INSERT_NO_COLUMNS: &'static str = " DEFAULT VALUES";
    const OFFSET_WITHOUT_LIMIT: Option<&'static str> = None;

    // Provided method
    fn write_placeholder(n: usize, out: &mut String) { ... }
}
Expand description

Default so a dialect can be produced where only its type is known: the render terminals take one as a value (.to_sql(Postgres)), which is what lets every builder before them infer it instead of being told.

Required Associated Constants§

Source

const IDENTIFIER_QUOTE: char

SQL identifier quote character, e.g. " for Postgres/SQLite, ` for MySQL.

Provided Associated Constants§

Source

const CAST_BIGINT: &'static str = "BIGINT"

How this dialect spells the two types an aggregate is cast back to. CAST itself is standard; the type names are not — MySQL takes SIGNED and DOUBLE where Postgres takes BIGINT and DOUBLE PRECISION.

Source

const CAST_DOUBLE: &'static str = "DOUBLE PRECISION"

Source

const PARENTHESIZED_SET_OP_BRANCHES: bool = true

Whether a set operation’s branches may be parenthesised. SQLite’s grammar has no place for a parenthesised SELECT around UNION.

Source

const INSERT_NO_COLUMNS: &'static str = " DEFAULT VALUES"

How to insert a row that names no column, which is what a table whose every column is generated leaves. INSERT INTO t () VALUES () is MySQL’s spelling and a syntax error everywhere else.

Source

const OFFSET_WITHOUT_LIMIT: Option<&'static str> = None

What to put in a LIMIT when a query has an OFFSET and no limit. Postgres takes a bare OFFSET; SQLite and MySQL don’t, and each spells “no limit” differently.

Provided Methods§

Source

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

Writes the placeholder for the nth bound parameter (1-indexed). Postgres numbers them ($1, $2, …); MySQL/SQLite are purely positional (? every time, matched by order of appearance).

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§