Skip to main content

Dialect

Trait Dialect 

Source
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§

Source

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.

Source

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.

Source

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.

Source

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§

Source

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.

Source

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.

Source

fn render_insert(&self, insert: &Insert) -> Result<Sql>

Render a borrowed INSERT query into SQL by cloning and delegating to Self::render_insert_owned.

Source

fn render_update(&self, update: &Update) -> Result<Sql>

Render a borrowed UPDATE query into SQL by cloning and delegating to Self::render_update_owned.

Source

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§

Source§

impl Dialect for MysqlDialect

Renders query ASTs into MySQL-compatible SQL with ? placeholders and backtick-quoted identifiers.

Source§

impl Dialect for PostgresDialect

Source§

impl Dialect for SqliteDialect

Renders query ASTs into SQLite-compatible SQL with ? placeholders and double-quoted identifiers.