pub trait Dialect {
// Required methods
fn render_select_owned(&self, select: Select) -> Result<Sql>;
fn render_insert_owned(&self, insert: Insert) -> Result<Sql>;
fn render_update_owned(&self, update: Update) -> Result<Sql>;
fn render_delete_owned(&self, delete: Delete) -> Result<Sql>;
// Provided methods
fn supports_returning(&self) -> bool { ... }
fn render_select(&self, select: &Select) -> Result<Sql> { ... }
fn render_insert(&self, insert: &Insert) -> Result<Sql> { ... }
fn render_update(&self, update: &Update) -> Result<Sql> { ... }
fn render_delete(&self, delete: &Delete) -> Result<Sql> { ... }
}Expand description
Trait for SQL dialect renderers.
Allows rendering AST queries into dialect-specific SQL strings.
Required Methods§
Sourcefn render_select_owned(&self, select: Select) -> Result<Sql>
fn render_select_owned(&self, select: Select) -> Result<Sql>
Render an owned SELECT query into SQL, moving bound values out of the AST instead of cloning them. This is the primary rendering entry point used by the engine’s hot paths; dialects implement this.
Sourcefn render_insert_owned(&self, insert: Insert) -> Result<Sql>
fn render_insert_owned(&self, insert: Insert) -> Result<Sql>
Render an owned INSERT query into SQL, moving bound values out of the AST instead of cloning them.
Sourcefn render_update_owned(&self, update: Update) -> Result<Sql>
fn render_update_owned(&self, update: Update) -> Result<Sql>
Render an owned UPDATE query into SQL, moving bound values out of the AST instead of cloning them.
Sourcefn render_delete_owned(&self, delete: Delete) -> Result<Sql>
fn render_delete_owned(&self, delete: Delete) -> Result<Sql>
Render an owned DELETE query into SQL, moving bound values out of the AST instead of cloning them.
Provided Methods§
Sourcefn supports_returning(&self) -> bool
fn supports_returning(&self) -> bool
Whether this dialect natively supports the RETURNING clause on INSERT, UPDATE, and DELETE statements.
Dialects that return false (e.g. MySQL) will have RETURNING
emulated at the connector layer via separate queries.
Sourcefn render_select(&self, select: &Select) -> Result<Sql>
fn render_select(&self, select: &Select) -> Result<Sql>
Render a borrowed SELECT query into SQL.
Clones the AST once and delegates to Self::render_select_owned. Used by
previews, tests, and other non-hot paths that only hold a &Select.
Sourcefn render_insert(&self, insert: &Insert) -> Result<Sql>
fn render_insert(&self, insert: &Insert) -> Result<Sql>
Render a borrowed INSERT query into SQL by cloning and delegating to
Self::render_insert_owned.
Sourcefn render_update(&self, update: &Update) -> Result<Sql>
fn render_update(&self, update: &Update) -> Result<Sql>
Render a borrowed UPDATE query into SQL by cloning and delegating to
Self::render_update_owned.
Sourcefn render_delete(&self, delete: &Delete) -> Result<Sql>
fn render_delete(&self, delete: &Delete) -> Result<Sql>
Render a borrowed DELETE query into SQL by cloning and delegating to
Self::render_delete_owned.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementors§
impl Dialect for MysqlDialect
Renders query ASTs into MySQL-compatible SQL with ? placeholders
and backtick-quoted identifiers.
impl Dialect for PostgresDialect
impl Dialect for SqliteDialect
Renders query ASTs into SQLite-compatible SQL with ? placeholders
and double-quoted identifiers.