Dialect

Trait Dialect 

Source
pub trait Dialect: Clone + Copy {
    // Required methods
    fn param(&self, idx: usize) -> String;
    fn bool_lit(&self, val: bool) -> &'static str;
    fn regex_op(&self) -> &'static str;
    fn in_clause(
        &self,
        field: &str,
        values: &[Value],
        start_idx: usize,
    ) -> (String, Vec<Value>);
    fn not_in_clause(
        &self,
        field: &str,
        values: &[Value],
        start_idx: usize,
    ) -> (String, Vec<Value>);
    fn supports_ilike(&self) -> bool;
    fn starts_with_clause(&self, field: &str, idx: usize) -> String;
    fn ends_with_clause(&self, field: &str, idx: usize) -> String;
    fn contains_clause(&self, field: &str, idx: usize) -> String;
}
Expand description

SQL dialect trait for database-specific syntax.

Required Methods§

Source

fn param(&self, idx: usize) -> String

Format a parameter placeholder (e.g., $1 for Postgres, ?1 for SQLite).

Source

fn bool_lit(&self, val: bool) -> &'static str

Format a boolean literal.

Source

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

Format the regex operator and pattern. Returns (operator, should_transform_pattern).

Source

fn in_clause( &self, field: &str, values: &[Value], start_idx: usize, ) -> (String, Vec<Value>)

Format an IN clause with multiple values. Returns the SQL fragment (e.g., = ANY($1) or IN (?1, ?2)).

Source

fn not_in_clause( &self, field: &str, values: &[Value], start_idx: usize, ) -> (String, Vec<Value>)

Format a NOT IN clause.

Source

fn supports_ilike(&self) -> bool

Whether ILIKE is supported natively.

Source

fn starts_with_clause(&self, field: &str, idx: usize) -> String

Format a STARTS WITH clause (e.g., LIKE $1 || '%' or LIKE ?1 || '%').

Source

fn ends_with_clause(&self, field: &str, idx: usize) -> String

Format an ENDS WITH clause (e.g., LIKE '%' || $1 or LIKE '%' || ?1).

Source

fn contains_clause(&self, field: &str, idx: usize) -> String

Format a CONTAINS clause (e.g., LIKE '%' || $1 || '%' or LIKE '%' || ?1 || '%').

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§