pub trait SqlDialect:
Database
+ HasStatementCache
+ Sized
+ Send
+ Syncwhere
Self::Connection: Send,{
Show 13 methods
// Required methods
fn placeholder(n: usize) -> String;
fn auto_increment_pk() -> &'static str;
fn rows_affected(res: &Self::QueryResult) -> u64;
fn last_insert_id(res: &Self::QueryResult) -> i64;
// Provided methods
fn supports_returning() -> bool { ... }
fn current_timestamp_fn() -> &'static str { ... }
fn int_type() -> &'static str { ... }
fn bigint_type() -> &'static str { ... }
fn text_type() -> &'static str { ... }
fn bool_type() -> &'static str { ... }
fn float_type() -> &'static str { ... }
fn blob_type() -> &'static str { ... }
fn quote_identifier(ident: &str) -> String { ... }
}Expand description
A trait that encapsulates all the requirements for a database to work with Premix.
Implementing this trait allows Premix to generate correct SQL syntax and handle database-specific behaviors like placeholder styles and identifier quoting.
Required Methods§
Sourcefn placeholder(n: usize) -> String
fn placeholder(n: usize) -> String
Returns the placeholder for the n-th parameter in a query (e.g., “?” or “$1”).
Sourcefn auto_increment_pk() -> &'static str
fn auto_increment_pk() -> &'static str
Returns the SQL fragment for an auto-incrementing Primary Key.
Sourcefn rows_affected(res: &Self::QueryResult) -> u64
fn rows_affected(res: &Self::QueryResult) -> u64
Returns the number of rows affected by a query result.
Sourcefn last_insert_id(res: &Self::QueryResult) -> i64
fn last_insert_id(res: &Self::QueryResult) -> i64
Returns the ID of the last inserted row.
Provided Methods§
Sourcefn supports_returning() -> bool
fn supports_returning() -> bool
Returns true if the database supports the RETURNING clause.
Sourcefn current_timestamp_fn() -> &'static str
fn current_timestamp_fn() -> &'static str
Returns the SQL function code for getting the current timestamp.
Sourcefn bigint_type() -> &'static str
fn bigint_type() -> &'static str
Returns the native SQL type for 64-bit integers.
Sourcefn float_type() -> &'static str
fn float_type() -> &'static str
Returns the native SQL type for floating-point numbers.
Sourcefn quote_identifier(ident: &str) -> String
fn quote_identifier(ident: &str) -> String
Quotes an identifier (table/column name) to prevent SQL injection.
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.
Implementations on Foreign Types§
Source§impl SqlDialect for Sqlite
Available on crate feature sqlite only.
impl SqlDialect for Sqlite
sqlite only.