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§
Sourcefn param(&self, idx: usize) -> String
fn param(&self, idx: usize) -> String
Format a parameter placeholder (e.g., $1 for Postgres, ?1 for SQLite).
Sourcefn regex_op(&self) -> &'static str
fn regex_op(&self) -> &'static str
Format the regex operator and pattern.
Returns (operator, should_transform_pattern).
Sourcefn in_clause(
&self,
field: &str,
values: &[Value],
start_idx: usize,
) -> (String, Vec<Value>)
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)).
Sourcefn not_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>)
Format a NOT IN clause.
Sourcefn supports_ilike(&self) -> bool
fn supports_ilike(&self) -> bool
Whether ILIKE is supported natively.
Sourcefn starts_with_clause(&self, field: &str, idx: usize) -> String
fn starts_with_clause(&self, field: &str, idx: usize) -> String
Format a STARTS WITH clause (e.g., LIKE $1 || '%' or LIKE ?1 || '%').
Sourcefn ends_with_clause(&self, field: &str, idx: usize) -> String
fn ends_with_clause(&self, field: &str, idx: usize) -> String
Format an ENDS WITH clause (e.g., LIKE '%' || $1 or LIKE '%' || ?1).
Sourcefn contains_clause(&self, field: &str, idx: usize) -> String
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.