Skip to main content

BindValues

Trait BindValues 

Source
pub trait BindValues: Database {
    // Required methods
    fn push_bind_value(query_builder: &mut QueryBuilder<'_, Self>, value: Value);
    fn push_bind_value_unseparated<Sep: Display>(
        separated: &mut Separated<'_, '_, Self, Sep>,
        value: Value,
    );
}
Expand description

A database the SQL helpers can write for.

It is one whose driver binds every raw value a domain model may filter on or store (Value’s variants: bool, i16, i32, i64, f32, f64, String and the chrono date/time types, each possibly NULL).

Implemented for every such sqlx database: Postgres, MySQL/MariaDB and SQLite, with sqlx’s chrono feature (sqlx::Any is not one, having no date/time types). Code generic over the database only needs DB: BindValues.

Required Methods§

Source

fn push_bind_value(query_builder: &mut QueryBuilder<'_, Self>, value: Value)

Bind value with its own SQL type; an absent value binds as a NULL of that type.

Source

fn push_bind_value_unseparated<Sep: Display>( separated: &mut Separated<'_, '_, Self, Sep>, value: Value, )

Bind value like BindValues::push_bind_value, into a separated list without a separator before it (e.g. right after column = ).

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§

Source§

impl<DB> BindValues for DB
where DB: Database, for<'q> Option<bool>: Encode<'q, DB> + Type<DB>, for<'q> Option<i16>: Encode<'q, DB> + Type<DB>, for<'q> Option<i32>: Encode<'q, DB> + Type<DB>, for<'q> Option<i64>: Encode<'q, DB> + Type<DB>, for<'q> Option<f32>: Encode<'q, DB> + Type<DB>, for<'q> Option<f64>: Encode<'q, DB> + Type<DB>, for<'q> Option<String>: Encode<'q, DB> + Type<DB>, for<'q> Option<DateTime<Utc>>: Encode<'q, DB> + Type<DB>, for<'q> Option<NaiveDateTime>: Encode<'q, DB> + Type<DB>, for<'q> Option<NaiveDate>: Encode<'q, DB> + Type<DB>, for<'q> Option<NaiveTime>: Encode<'q, DB> + Type<DB>,