pub struct WhereBuilder<D: Dialect> { /* private fields */ }Expand description
Accumulator passed to and_where/or_where closures.
It owns its own Vec<Predicate>; the closure consumes it and returns it,
and the caller wraps the collected predicates into a Predicate::Group.
The PhantomData<D> keeps the dialect in scope without threading the full
builder through the closure.
Siblings added directly are AND-joined; call and_where/or_where inside
the closure to nest a further parenthesized group (and or_where introduces
OR within the group). Nesting is arbitrary-depth.
Implementations§
Source§impl<D: Dialect> WhereBuilder<D>
impl<D: Dialect> WhereBuilder<D>
Sourcepub fn and_where(
self,
f: impl FnOnce(WhereBuilder<D>) -> WhereBuilder<D>,
) -> Self
pub fn and_where( self, f: impl FnOnce(WhereBuilder<D>) -> WhereBuilder<D>, ) -> Self
Add a nested parenthesized AND (...) group built by the closure.
Sourcepub fn or_where(
self,
f: impl FnOnce(WhereBuilder<D>) -> WhereBuilder<D>,
) -> Self
pub fn or_where( self, f: impl FnOnce(WhereBuilder<D>) -> WhereBuilder<D>, ) -> Self
Add a nested parenthesized OR (...) group built by the closure.
Sourcepub fn where_like(self, col: &str, val: impl IntoBind) -> Self
pub fn where_like(self, col: &str, val: impl IntoBind) -> Self
col LIKE val.
Sourcepub fn where_ilike(self, col: &str, val: impl IntoBind) -> Self
pub fn where_ilike(self, col: &str, val: impl IntoBind) -> Self
col ILIKE val — dialect-aware case-insensitive match (see
QueryBuilder::where_ilike).
Sourcepub fn where_jsonb_contains(self, col: &str, val: impl IntoBind) -> Self
pub fn where_jsonb_contains(self, col: &str, val: impl IntoBind) -> Self
col @> val — JSONB containment (Postgres-oriented; see
QueryBuilder::where_jsonb_contains).
Sourcepub fn where_in(
self,
col: &str,
vals: impl IntoIterator<Item = impl IntoBind>,
) -> Self
pub fn where_in( self, col: &str, vals: impl IntoIterator<Item = impl IntoBind>, ) -> Self
col IN (...).
Sourcepub fn where_not_in(
self,
col: &str,
vals: impl IntoIterator<Item = impl IntoBind>,
) -> Self
pub fn where_not_in( self, col: &str, vals: impl IntoIterator<Item = impl IntoBind>, ) -> Self
col NOT IN (...).
Sourcepub fn where_null(self, col: &str) -> Self
pub fn where_null(self, col: &str) -> Self
col IS NULL.
Sourcepub fn where_not_null(self, col: &str) -> Self
pub fn where_not_null(self, col: &str) -> Self
col IS NOT NULL.
Sourcepub fn where_between(
self,
col: &str,
lo: impl IntoBind,
hi: impl IntoBind,
) -> Self
pub fn where_between( self, col: &str, lo: impl IntoBind, hi: impl IntoBind, ) -> Self
col BETWEEN lo AND hi.
Sourcepub fn where_raw(self, sql: &str, binds: Vec<Value>) -> Self
pub fn where_raw(self, sql: &str, binds: Vec<Value>) -> Self
Raw SQL predicate with its own binds — the verbatim escape hatch.
§Warning: positional placeholder contract
sql is emitted verbatim (it is NOT escaped or renumbered) and
binds are appended to the running bind list in order. For
Postgres, the caller MUST write $N numbers matching the actual
bind position — that is, number of binds already accumulated + 1, +2,
… For MySQL/SQLite use ?. No renumbering is performed, so a wrong $N
produces a malformed query.
Sourcepub fn where_column(self, lhs: &str, op: &'static str, rhs: &str) -> Self
pub fn where_column(self, lhs: &str, op: &'static str, rhs: &str) -> Self
lhs op rhs — compare two column identifiers (both escaped at compile
time), no bind. See
QueryBuilder::where_column.
Trait Implementations§
Auto Trait Implementations§
impl<D> Freeze for WhereBuilder<D>
impl<D> RefUnwindSafe for WhereBuilder<D>where
D: RefUnwindSafe,
impl<D> Send for WhereBuilder<D>
impl<D> Sync for WhereBuilder<D>
impl<D> Unpin for WhereBuilder<D>where
D: Unpin,
impl<D> UnsafeUnpin for WhereBuilder<D>
impl<D> UnwindSafe for WhereBuilder<D>where
D: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more