Skip to main content

SqlDialect

Trait SqlDialect 

Source
pub trait SqlDialect:
    Database
    + HasStatementCache
    + Sized
    + Send
    + Sync
where 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§

Source

fn placeholder(n: usize) -> String

Returns the placeholder for the n-th parameter in a query (e.g., “?” or “$1”).

Source

fn auto_increment_pk() -> &'static str

Returns the SQL fragment for an auto-incrementing Primary Key.

Source

fn rows_affected(res: &Self::QueryResult) -> u64

Returns the number of rows affected by a query result.

Source

fn last_insert_id(res: &Self::QueryResult) -> i64

Returns the ID of the last inserted row.

Provided Methods§

Source

fn supports_returning() -> bool

Returns true if the database supports the RETURNING clause.

Source

fn current_timestamp_fn() -> &'static str

Returns the SQL function code for getting the current timestamp.

Source

fn int_type() -> &'static str

Returns the native SQL type for 32-bit integers.

Source

fn bigint_type() -> &'static str

Returns the native SQL type for 64-bit integers.

Source

fn text_type() -> &'static str

Returns the native SQL type for text strings.

Source

fn bool_type() -> &'static str

Returns the native SQL type for booleans.

Source

fn float_type() -> &'static str

Returns the native SQL type for floating-point numbers.

Source

fn blob_type() -> &'static str

Returns the native SQL type for binary data.

Source

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.

Implementors§