pub trait SqlDialect:
Send
+ Sync
+ Sealed {
// Required methods
fn placeholder(&self, i: usize) -> String;
fn returning_clause(&self, cols: &str) -> String;
fn quote_ident(&self, ident: &str) -> String;
fn upsert_clause(&self, conflict_cols: &[&str], update_set: &str) -> String;
// Provided methods
fn supports_distinct_on(&self) -> bool { ... }
fn insert_has_returning(&self) -> bool { ... }
fn begin_sql(&self) -> &'static str { ... }
fn commit_sql(&self) -> &'static str { ... }
fn rollback_sql(&self) -> &'static str { ... }
}Expand description
Cross-dialect SQL emission helpers.
Implementations describe a single database backend’s syntax choices.
Engines return &dyn SqlDialect from QueryEngine::dialect().
Required Methods§
Sourcefn placeholder(&self, i: usize) -> String
fn placeholder(&self, i: usize) -> String
Emit the 1-indexed parameter placeholder for position i.
Sourcefn returning_clause(&self, cols: &str) -> String
fn returning_clause(&self, cols: &str) -> String
Emit the clause (leading space included) that requests the given
columns be returned after an INSERT/UPDATE/DELETE. Postgres/SQLite/MySQL
emit RETURNING cols; MSSQL emits OUTPUT INSERTED.cols.
Sourcefn quote_ident(&self, ident: &str) -> String
fn quote_ident(&self, ident: &str) -> String
Quote a table/column identifier for safe interpolation.
Sourcefn upsert_clause(&self, conflict_cols: &[&str], update_set: &str) -> String
fn upsert_clause(&self, conflict_cols: &[&str], update_set: &str) -> String
Emit the ON CONFLICT / ON DUPLICATE KEY clause (leading space included) that converts an INSERT into an upsert.
Provided Methods§
Sourcefn supports_distinct_on(&self) -> bool
fn supports_distinct_on(&self) -> bool
Whether the dialect supports SELECT DISTINCT ON (cols) (Postgres-only
among our backends today).
Sourcefn insert_has_returning(&self) -> bool
fn insert_has_returning(&self) -> bool
Whether an INSERT statement can use the dialect’s returning clause to retrieve inserted rows in-place.
Sourcefn commit_sql(&self) -> &'static str
fn commit_sql(&self) -> &'static str
SQL keyword that commits a transaction. Defaults to COMMIT.
Sourcefn rollback_sql(&self) -> &'static str
fn rollback_sql(&self) -> &'static str
SQL keyword that rolls back a transaction. Defaults to ROLLBACK.