Skip to main content

ISqlGenerator

Trait ISqlGenerator 

Source
pub trait ISqlGenerator: Send + Sync {
    // Required methods
    fn select(&self, table: &str, columns: &[&str]) -> String;
    fn insert(&self, table: &str, columns: &[&str], returning: bool) -> String;
    fn update(
        &self,
        table: &str,
        set_columns: &[&str],
        where_clause: &str,
    ) -> String;
    fn delete(&self, table: &str, where_clause: &str) -> String;
    fn create_table(&self, table: &str, columns: &[(String, String)]) -> String;
    fn drop_table(&self, table: &str) -> String;
    fn pagination(&self, skip: Option<usize>, take: Option<usize>) -> String;
    fn parameter_placeholder(&self, index: usize) -> String;
    fn quote_identifier(&self, identifier: &str) -> String;
    fn auto_increment_syntax(&self) -> &'static str;

    // Provided method
    fn insert_batch(
        &self,
        table: &str,
        columns: &[&str],
        row_count: usize,
    ) -> String { ... }
}
Expand description

Represents a SQL dialect with specific syntax for common operations.

Required Methods§

Source

fn select(&self, table: &str, columns: &[&str]) -> String

Generates a SELECT statement.

Source

fn insert(&self, table: &str, columns: &[&str], returning: bool) -> String

Generates an INSERT statement.

Source

fn update( &self, table: &str, set_columns: &[&str], where_clause: &str, ) -> String

Generates an UPDATE statement.

Source

fn delete(&self, table: &str, where_clause: &str) -> String

Generates a DELETE statement.

Source

fn create_table(&self, table: &str, columns: &[(String, String)]) -> String

Generates a CREATE TABLE statement.

Source

fn drop_table(&self, table: &str) -> String

Generates a DROP TABLE statement.

Source

fn pagination(&self, skip: Option<usize>, take: Option<usize>) -> String

Generates a pagination clause.

Source

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

Returns the parameter placeholder (e.g., $1 for PG, ? for MySQL).

Source

fn quote_identifier(&self, identifier: &str) -> String

Returns the identifier quoting character (e.g., " for PG, ` for MySQL).

Source

fn auto_increment_syntax(&self) -> &'static str

Returns the dialect-specific auto-increment syntax.

Provided Methods§

Source

fn insert_batch( &self, table: &str, columns: &[&str], row_count: usize, ) -> String

Generates a multi-row INSERT statement with row_count value groups (INSERT INTO t (c1, c2) VALUES (?, ?), (?, ?), ...). Placeholders follow the dialect’s numbering (? for SQLite/MySQL, $n for PG).

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§