Skip to main content

SqlDialect

Trait SqlDialect 

Source
pub trait SqlDialect: Send + Sync {
    // Required methods
    fn placeholder(&self, index: usize) -> String;
    fn quote_ident(&self, name: &str) -> String;
    fn sql_type(&self, col_type: &ColumnType) -> String;
    fn supports_returning(&self) -> bool;
    fn upsert_syntax(&self) -> UpsertSyntax;
}
Expand description

SQL dialect controls syntax differences between backends.

Required Methods§

Source

fn placeholder(&self, index: usize) -> String

Placeholder style: $1 for Postgres, ? for MySQL.

Source

fn quote_ident(&self, name: &str) -> String

Quote an identifier (table name, column name).

Source

fn sql_type(&self, col_type: &ColumnType) -> String

Map a ColumnType to dialect-specific SQL type string.

Source

fn supports_returning(&self) -> bool

Whether RETURNING clause is supported (Postgres yes, MySQL no).

Source

fn upsert_syntax(&self) -> UpsertSyntax

Whether INSERT OR IGNORE / ON CONFLICT DO NOTHING is supported.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§