Skip to main content

Filter

Struct Filter 

Source
pub struct Filter(/* private fields */);
Expand description

A typed condition on its way to a WHERE.

What a Column comparison produces. It is three things at once, which is what lets typed filters mix with Layer 1 anywhere:

  • a Mod on anything with a WHERE (HasWhere) — so it sits directly in users::table().query((users::age().gte(21), …)), and equally in a raw dialect statement’s mod tuple;
  • an IntoExpr — so it drops into any expression slot (select::where_, a join’s on, a CASE arm);
  • a Chain — so .and(…), .or(…) and every other Layer 1 operator keep working after the typed comparison started the chain.

Implementations§

Source§

impl Filter

Source

pub fn new(condition: impl IntoExpr) -> Filter

Wrap any expression — a raw &str fragment included — as a filter, so hand-written SQL rides the same WHERE path the typed comparisons use.

Trait Implementations§

Source§

impl Chain for Filter

Source§

fn from_expr(e: Expr) -> Filter

Wrap a finished expression back into the chain type. Read more
Source§

fn step(self, f: impl FnOnce(Expr) -> Expr) -> Self

One chain step: build a node from this expression, apply the parenthesisation rule, and return a chain again. Read more
Source§

fn op(self, op: &'static str, rhs: impl IntoExpr) -> Self

An arbitrary infix operator: self op rhs. Read more
Source§

fn eq(self, rhs: impl IntoExpr) -> Self

self = rhs.
Source§

fn ne(self, rhs: impl IntoExpr) -> Self

self <> rhs. The standard spelling, which every dialect accepts.
Source§

fn lt(self, rhs: impl IntoExpr) -> Self

self < rhs.
Source§

fn lte(self, rhs: impl IntoExpr) -> Self

self <= rhs.
Source§

fn gt(self, rhs: impl IntoExpr) -> Self

self > rhs.
Source§

fn gte(self, rhs: impl IntoExpr) -> Self

self >= rhs.
Source§

fn in_(self, vals: impl IntoExprList) -> Self

self IN (a, b, c). Read more
Source§

fn not_in(self, vals: impl IntoExprList) -> Self

self NOT IN (a, b, c).
Source§

fn is_null(self) -> Self

self IS NULL.
Source§

fn is_not_null(self) -> Self

self IS NOT NULL.
Source§

fn is_distinct_from(self, rhs: impl IntoExpr) -> Self

self IS DISTINCT FROM rhs.
Source§

fn is_not_distinct_from(self, rhs: impl IntoExpr) -> Self

self IS NOT DISTINCT FROM rhs.
Source§

fn between(self, a: impl IntoExpr, b: impl IntoExpr) -> Self

self BETWEEN a AND b.
Source§

fn not_between(self, a: impl IntoExpr, b: impl IntoExpr) -> Self

self NOT BETWEEN a AND b.
Source§

fn like(self, rhs: impl IntoExpr) -> Self

self LIKE rhs.
Source§

fn concat(self, others: impl IntoExprList) -> Self

self || a || b — string concatenation.
Source§

fn and(self, others: impl IntoExprList) -> Self

self AND a AND b.
Source§

fn or(self, others: impl IntoExprList) -> Self

self OR a OR b.
Source§

fn plus(self, rhs: impl IntoExpr) -> Self

self + rhs.
Source§

fn minus(self, rhs: impl IntoExpr) -> Self

self - rhs.
Source§

fn as_(self, alias: impl IntoIdent) -> Expr

self AS "alias". Read more
Source§

impl Clone for Filter

Source§

fn clone(&self) -> Filter

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 Filter

Source§

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

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

impl IntoExpr for Filter

Source§

fn into_expr(self) -> Expr

Perform the conversion.
Source§

impl IntoExprList for Filter

Source§

fn into_expr_list(self) -> Vec<Expr>

Perform the conversion.
Source§

impl<Q: HasWhere> Mod<Q> for Filter

Appends to the WHERE clause; several filters AND together, matching Where’s own contract.

Source§

fn apply(self, q: &mut Q)

Apply this modification to q.

Auto Trait Implementations§

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> 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> 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> 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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.