pub struct Col<V: 'static> {
pub column: &'static str,
pub field: &'static str,
pub owner: &'static str,
/* private fields */
}Expand description
A typed column reference, what Trip::name() returns (the derive emits one inherent fn
per persisted field). It knows the column’s name and its stored encoding, so a predicate
built from it compares in the column’s stored language whatever codec the field uses.
Fields§
§column: &'static str§field: &'static strThe struct field this column stores. The change log speaks field names and the SQL
speaks column names; they differ under #[model(column = "…")], and a relation is
wired by field, so a predicate that crosses one needs both.
owner: &'static strThe table this column belongs to, which disambiguates a relation when two models happen to name a field alike.
Implementations§
Source§impl<V> Col<V>
impl<V> Col<V>
pub const fn new( column: &'static str, field: &'static str, owner: &'static str, encode: fn(&V) -> Value, ) -> Col<V>
pub fn eq(self, v: impl Borrow<V>) -> Pred
pub fn ne(self, v: impl Borrow<V>) -> Pred
pub fn lt(self, v: impl Borrow<V>) -> Pred
pub fn le(self, v: impl Borrow<V>) -> Pred
pub fn gt(self, v: impl Borrow<V>) -> Pred
pub fn ge(self, v: impl Borrow<V>) -> Pred
Sourcepub fn is_in(self, values: impl IntoIterator<Item = impl Borrow<V>>) -> Pred
pub fn is_in(self, values: impl IntoIterator<Item = impl Borrow<V>>) -> Pred
column ∈ values, each encoded through this column’s own codec exactly as eq does.
An empty set matches nothing, in both evaluation paths.
Sourcepub fn not_in(self, values: impl IntoIterator<Item = impl Borrow<V>>) -> Pred
pub fn not_in(self, values: impl IntoIterator<Item = impl Borrow<V>>) -> Pred
The complement of Col::is_in, with SQL’s NULL rule: a NULL column is unknown, so
it is not selected; not_in is therefore not the same as !is_in over nullable
columns, exactly as in SQL.
Sourcepub fn is_not_null(self) -> Pred
pub fn is_not_null(self) -> Pred
column IS NOT NULL.
pub fn between(self, lo: impl Borrow<V>, hi: impl Borrow<V>) -> Pred
pub fn asc(self) -> Sort
pub fn desc(self) -> Sort
Source§impl Col<String>
impl Col<String>
Sourcepub fn starts_with(self, prefix: impl Into<String>) -> Pred
pub fn starts_with(self, prefix: impl Into<String>) -> Pred
Case-sensitive prefix match.
Sourcepub fn starts_with_ci(self, prefix: impl Into<String>) -> Pred
pub fn starts_with_ci(self, prefix: impl Into<String>) -> Pred
Case-insensitive prefix match.
Sourcepub fn contains_ci(self, needle: impl Into<String>) -> Pred
pub fn contains_ci(self, needle: impl Into<String>) -> Pred
Case-insensitive substring, what a search field wants.
Source§impl<M: Model> Col<One<M>>
Predicates over a to-one reference column: the identity and presence tests, which need
nothing but the foreign-key column already stored here.
impl<M: Model> Col<One<M>>
Predicates over a to-one reference column: the identity and presence tests, which need nothing but the foreign-key column already stored here.
Sourcepub fn is_one_of(
self,
ids: impl IntoIterator<Item = impl Into<ModelId<M>>>,
) -> Pred
pub fn is_one_of( self, ids: impl IntoIterator<Item = impl Into<ModelId<M>>>, ) -> Pred
The reference points at one of these rows: the set form, and what a query feeding
another query compiles to. (Named apart from the generic crate::Col::is_in, which
takes One values; this one takes ids, which is what a caller holds.)
Source§impl<M: Model> Col<One<M>>
Traversing a to-one reference in a predicate: “lodgings whose trip is done”. A to-one is
a to-many of at most one, so the quantifier vocabulary is the same one the Many side
uses; any reads as “its target matches, and there is one”.
impl<M: Model> Col<One<M>>
Traversing a to-one reference in a predicate: “lodgings whose trip is done”. A to-one is
a to-many of at most one, so the quantifier vocabulary is the same one the Many side
uses; any reads as “its target matches, and there is one”.
Source§impl<M: Model> Col<Option<One<M>>>
The same tests over a nullable reference (Option<One<M>>), which is what a relation with
a nullify delete rule requires the child to hold.
impl<M: Model> Col<Option<One<M>>>
The same tests over a nullable reference (Option<One<M>>), which is what a relation with
a nullify delete rule requires the child to hold.
Trait Implementations§
Auto Trait Implementations§
impl<V> Forget for Col<V>
impl<V> Freeze for Col<V>
impl<V> Move for Col<V>
impl<V> RefUnwindSafe for Col<V>
impl<V> Send for Col<V>
impl<V> Sync for Col<V>
impl<V> Unpin for Col<V>
impl<V> UnsafeUnpin for Col<V>
impl<V> UnwindSafe for Col<V>
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<T> ErasedDestructor for Twhere
T: 'static,
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