Skip to main content

QueryBuilder

Trait QueryBuilder 

Source
pub trait QueryBuilder<DB: Backend> {
    // Required methods
    fn push_sql(&mut self, sql: &str);
    fn push_identifier(&mut self, identifier: &str) -> QueryResult<()>;
    fn push_bind_param(&mut self);
    fn finish(self) -> String;

    // Provided method
    fn push_bind_param_value_only(&mut self) { ... }
}
Expand description

Constructs a SQL query from a Diesel AST.

The only reason you should ever need to interact with this trait is if you are extending Diesel with support for a new backend. Plugins which extend the query builder with new capabilities will interact with AstPass instead.

Required Methods§

Source

fn push_sql(&mut self, sql: &str)

Add sql to the end of the query being constructed.

Source

fn push_identifier(&mut self, identifier: &str) -> QueryResult<()>

Quote identifier, and add it to the end of the query being constructed.

Source

fn push_bind_param(&mut self)

Add a placeholder for a bind parameter to the end of the query being constructed.

Source

fn finish(self) -> String

Returns the constructed SQL query.

Provided Methods§

Source

fn push_bind_param_value_only(&mut self)

Increases the internal counter for bind parameters without adding the bind parameter itself to the query

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§

Source§

impl QueryBuilder<Mysql> for MysqlQueryBuilder

Available on crate feature mysql_backend only.
Source§

impl QueryBuilder<Pg> for PgQueryBuilder

Available on crate feature postgres_backend only.
Source§

impl QueryBuilder<Sqlite> for SqliteQueryBuilder

Available on crate feature __sqlite-shared only.