Skip to main content

Pred

Enum Pred 

Source
pub enum Pred {
Show 22 variants Always, Eq(&'static str, Value), Ne(&'static str, Value), Lt(&'static str, Value), Le(&'static str, Value), Gt(&'static str, Value), Ge(&'static str, Value), Contains(&'static str, String), ContainsCi(&'static str, String), StartsWith(&'static str, String), StartsWithCi(&'static str, String), Between(&'static str, Value, Value), In(&'static str, Vec<Value>), NotIn(&'static str, Vec<Value>), IdIn(Vec<u64>), Related { owner: &'static str, field: &'static str, target: &'static str, quant: Quant, inner: Box<Pred>, }, And(Box<Pred>, Box<Pred>), Or(Box<Pred>, Box<Pred>), Not(Box<Pred>), Raw(String, Vec<Value>), Matches { columns: &'static [&'static str], query: String, }, Within { lat: &'static str, lon: &'static str, min_lat: f64, max_lat: f64, min_lon: f64, max_lon: f64, },
}
Expand description

A predicate as a value. Compiles to SQL; the fallback evaluator (Pred::eval) exists for drivers that cannot fold case exactly, and for tests.

Variants§

§

Always

§

Eq(&'static str, Value)

§

Ne(&'static str, Value)

§

Lt(&'static str, Value)

§

Le(&'static str, Value)

§

Gt(&'static str, Value)

§

Ge(&'static str, Value)

§

Contains(&'static str, String)

Case-sensitive substring on a TEXT column (SQL: instr(col, ?) > 0).

§

ContainsCi(&'static str, String)

Case-insensitive substring, what a search field wants. Folds with full Unicode lowercasing on both paths: the driver registers day_fold (Rust’s to_lowercase as a SQL function), so the SQL form selects exactly the rows the in-memory form would.

§

StartsWith(&'static str, String)

Case-sensitive prefix. Not LIKE, whose SQLite default is case-insensitive for ASCII and would quietly answer the wrong question.

§

StartsWithCi(&'static str, String)

Case-insensitive prefix through day_fold, like Pred::ContainsCi.

§

Between(&'static str, Value, Value)

§

In(&'static str, Vec<Value>)

column ∈ set. The set is sorted and deduped at construction, so the fallback evaluator can binary-search it.

§

NotIn(&'static str, Vec<Value>)

column ∉ set, with SQL’s NULL rule: a NULL column is unknown, not a match.

§

IdIn(Vec<u64>)

The row’s key ∈ set. Compiles against the key column directly.

§

Related

A question about a row’s relatives: “some lodging of this trip is in Kyoto”. Compiles to a correlated EXISTS over the relation’s foreign key (or join table); inner evaluates against rows of target, not of the query’s own table. Nesting is unlimited; each level is another subquery the engine plans.

Fields

§owner: &'static str

The table declaring the relation, which tells two like-named fields apart.

§field: &'static str

The Many field, or the One column’s field name, that was crossed.

§target: &'static str
§quant: Quant
§inner: Box<Pred>
§

And(Box<Pred>, Box<Pred>)

§

Or(Box<Pred>, Box<Pred>)

§

Not(Box<Pred>)

§

Raw(String, Vec<Value>)

Raw SQL the layer cannot read. The query cannot know its dependencies, so every flush that touches the table re-runs it. That is the cost of the escape hatch.

§

Matches

Full-text match (#[model(fts(…))]): compiles to a subquery over the FTS5 shadow. The dependency set is the indexed columns, so the zero-cost tier survives search.

Fields

§columns: &'static [&'static str]
§query: String
§

Within

A bounding-box test over two REAL columns. When the columns are the model’s declared spatial(…) pair, the compiler narrows through the R*Tree shadow first and re-checks exactly (the shadow stores 32-bit floats, outward-rounded, as a candidate superset).

Fields

§lat: &'static str
§lon: &'static str
§min_lat: f64
§max_lat: f64
§min_lon: f64
§max_lon: f64

Implementations§

Source§

impl Pred

Source

pub fn columns(&self, out: &mut Vec<&'static str>)

The columns whose change can move a result through this predicate: local columns only; what a predicate reads across a relation is collected by Pred::related_deps.

Source

pub fn contains_raw(&self) -> bool

Whether any part is raw SQL (unreadable, so every flush of the table re-queries).

Source

pub fn eval(&self, key: u64, row: &dyn RowView) -> bool

Whether this row matches, in the WHERE-clause reading: unknown is not a match. This is the fallback evaluator; the SQL compiler is the primary path, and this answers for drivers without day_fold (over the row’s own columns; relation crossings are refused upstream) and for unit tests. Raw and Matches answer true here: on the fallback path they have already filtered in SQL.

Source

pub fn eval3(&self, key: u64, row: &dyn RowView) -> Option<bool>

Pred::eval, three-valued: SQL’s logic, which is the only way this path and the SQL path can agree about NULL.

A comparison against a NULL column is unknown (None), not false: SQL’s notes <> 'x' does not select rows whose notes is NULL, and neither does this. Eq/Ne against a Null literal keep their IS NULL / IS NOT NULL meaning and are always definite.

Trait Implementations§

Source§

impl BitAnd for Pred

Source§

type Output = Pred

The resulting type after applying the & operator.
Source§

fn bitand(self, rhs: Pred) -> Pred

Performs the & operation. Read more
Source§

impl BitOr for Pred

Source§

type Output = Pred

The resulting type after applying the | operator.
Source§

fn bitor(self, rhs: Pred) -> Pred

Performs the | operation. Read more
Source§

impl Clone for Pred

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Pred

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Not for Pred

Source§

type Output = Pred

The resulting type after applying the ! operator.
Source§

fn not(self) -> Pred

Performs the unary ! operation using logical or bitwise negation. Read more
Source§

impl PartialEq for Pred

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Pred

Auto Trait Implementations§

§

impl Forget for Pred

§

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> AnyEq for T
where T: Any + PartialEq,

Source§

fn equals(&self, other: &(dyn Any + 'static)) -> bool

Source§

fn as_any(&self) -> &(dyn Any + 'static)

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> IntoReactive<T, StaticMark> for T
where T: Clone + 'static,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.