QueryBuilder

Struct QueryBuilder 

Source
pub struct QueryBuilder<'conn, 'q> { /* private fields */ }
Expand description

Fluent builder for query execution with optional placeholder translation.

Implementations§

Source§

impl QueryBuilder<'_, '_>

Source

pub async fn dml(self) -> Result<usize, SqlMiddlewareDbError>

Execute a DML statement and return rows affected.

§Errors

Returns an error if placeholder translation fails or the backend DML execution fails.

Source§

impl QueryBuilder<'_, '_>

Source

pub async fn select(self) -> Result<ResultSet, SqlMiddlewareDbError>

Execute a SELECT and return the result set.

§Errors

Returns an error if placeholder translation fails or the backend query execution fails.

Source§

impl<'conn, 'q> QueryBuilder<'conn, 'q>

Source

pub fn params(self, params: &'q [RowValues]) -> Self

Provide parameters for this statement.

Source

pub fn options(self, options: QueryOptions) -> Self

Override translation using QueryOptions.

Source

pub fn translation(self, translation: TranslationMode) -> Self

Override translation mode directly.

Warning: translation skips placeholders inside quoted strings, comments, and dollar-quoted blocks via a lightweight state machine; it may miss edge cases in complex SQL (e.g., PL/pgSQL bodies). Prefer backend-specific SQL instead of relying on translation:

let query = match conn {
    MiddlewarePoolConnection::Postgres { .. } => r#"$function$
BEGIN
    RETURN ($1 ~ $q$[\t\r\n\v\\]$q$);
END;
$function$"#,
    MiddlewarePoolConnection::Sqlite { .. } | MiddlewarePoolConnection::Turso { .. } => {
        include_str!("../sql/functions/sqlite/03_sp_get_scores.sql")
    }
};

Auto Trait Implementations§

§

impl<'conn, 'q> Freeze for QueryBuilder<'conn, 'q>

§

impl<'conn, 'q> !RefUnwindSafe for QueryBuilder<'conn, 'q>

§

impl<'conn, 'q> Send for QueryBuilder<'conn, 'q>

§

impl<'conn, 'q> Sync for QueryBuilder<'conn, 'q>

§

impl<'conn, 'q> Unpin for QueryBuilder<'conn, 'q>

§

impl<'conn, 'q> !UnwindSafe for QueryBuilder<'conn, 'q>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V