pub enum Predicate<D: Dialect> {
Binary {
col: String,
op: &'static str,
val: Value,
},
In {
col: String,
neg: bool,
vals: Vec<Value>,
},
Null {
col: String,
neg: bool,
},
Between {
col: String,
lo: Value,
hi: Value,
},
ILike {
col: String,
val: Value,
},
JsonContains {
col: String,
val: Value,
},
Raw {
sql: String,
binds: Vec<Value>,
},
Group {
outer_conj: Conj,
preds: Vec<Predicate<D>>,
},
Column {
lhs: String,
op: &'static str,
rhs: String,
},
Exists {
neg: bool,
sub: Box<QueryBuilder<D>>,
},
InSubquery {
col: String,
neg: bool,
sub: Box<QueryBuilder<D>>,
},
}Expand description
A single WHERE-clause predicate.
Generic over the Dialect marker D because subquery-bearing variants
(Predicate::Exists / Predicate::InSubquery) embed a
QueryBuilder<D>; the recursion is broken with a Box.
Variants§
Binary
col op value, e.g. "age" > $1.
Fields
In
col [NOT ]IN (...).
Fields
Null
col IS [NOT ]NULL.
Between
col BETWEEN lo AND hi.
Fields
ILike
col ILIKE val — dialect-aware case-insensitive match.
Postgres emits native {col} ILIKE {ph}; MySQL/SQLite emit
LOWER({col}) LIKE LOWER({ph}). Dispatched in compile::write_pred.
JsonContains
col @> val — JSONB containment (Postgres-oriented; @> emitted
verbatim for all dialects).
Fields
Raw
Raw SQL fragment with its own binds, emitted verbatim.
Group
A parenthesized group of predicates.
outer_conj controls how the group attaches to the preceding clause
(AND (...) vs OR (...)). Inner predicates are joined with AND,
except that a nested Group carries its own outer_conj (so or_where
inside a group emits OR (...)) — groups nest arbitrarily.
Fields
Column
lhs op rhs — both sides are column identifiers (escaped at compile
time), no bind. Backs where_column.
Fields
Exists
[NOT ]EXISTS (subquery).
Fields
sub: Box<QueryBuilder<D>>The embedded sub-query, compiled with placeholder continuity.
InSubquery
col [NOT ]IN (subquery).
Trait Implementations§
Source§impl<D: PartialEq + Dialect> PartialEq for Predicate<D>
impl<D: PartialEq + Dialect> PartialEq for Predicate<D>
impl<D: Dialect> StructuralPartialEq for Predicate<D>
Auto Trait Implementations§
impl<D> Freeze for Predicate<D>
impl<D> RefUnwindSafe for Predicate<D>where
D: RefUnwindSafe,
impl<D> Send for Predicate<D>
impl<D> Sync for Predicate<D>
impl<D> Unpin for Predicate<D>
impl<D> UnsafeUnpin for Predicate<D>
impl<D> UnwindSafe for Predicate<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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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