pub enum Pred {
Cmp {
field: String,
op: String,
value: Value,
},
In {
field: String,
values: Vec<Value>,
negated: bool,
},
Between {
field: String,
low: Value,
high: Value,
negated: bool,
},
Like {
field: String,
pattern: String,
negated: bool,
ci: bool,
},
Regex {
field: String,
pattern: String,
negated: bool,
ci: bool,
},
IsNull {
field: String,
negated: bool,
},
And(Vec<Pred>),
Or(Vec<Pred>),
Not(Box<Pred>),
}Expand description
A boolean predicate tree.
The old representation was Vec<WhereClause> evaluated with .all(), which
can only ever express a conjunction of comparisons. A tree is required for
OR, for NOT, and for parenthesised grouping — WHERE (a = 1 OR b = 2) AND c != 3 has no encoding as a flat list.
Variants§
Cmp
field
In
field [NOT] IN (v1, v2, …)
Between
field [NOT] BETWEEN low AND high — inclusive on both ends, as in SQL.
Like
field [NOT] LIKE “pat” — SQL wildcards: % = any run, _ = any one char.
ci is set by ILIKE (case-insensitive).
Regex
field ~ "pat" / field !~ "pat" — POSIX regex match, over a
DOCUMENTED SUBSET. ci is set by ~* / !~*.
Exists because Postgres catalogue introspection needs it: psql’s
\dn filters with nspname !~ '^pg_', and \dt with
nspname !~ '^pg_toast'. Without the operator those queries cannot
run at all.
The subset is ^, $, ., and literal text — which is everything
those queries actually use. A pattern containing any other
metacharacter is REFUSED with an error naming it, rather than matched
approximately. Approximate regex matching on a catalogue filter would
silently include or exclude schemas, and a wrong schema list looks
exactly like a correct one.
Deliberately no regex crate: it would add a dependency tree to an
engine whose small footprint is a selling point, to serve two anchored
prefix patterns.
IsNull
field IS [NOT] NULL — true when the field is JSON null OR absent.
And(Vec<Pred>)
Or(Vec<Pred>)
Not(Box<Pred>)
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Pred
impl RefUnwindSafe for Pred
impl Send for Pred
impl Sync for Pred
impl Unpin for Pred
impl UnsafeUnpin for Pred
impl UnwindSafe for Pred
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,
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
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