ExprExt

Trait ExprExt 

Source
pub trait ExprExt<'a, V: SQLParam>: Expr<'a, V> + Sized {
Show 14 methods // Provided methods fn eq<R>(self, other: R) -> SQLExpr<'a, V, Bool, NonNull, Scalar> where R: Expr<'a, V>, Self::SQLType: Compatible<R::SQLType> { ... } fn ne<R>(self, other: R) -> SQLExpr<'a, V, Bool, NonNull, Scalar> where R: Expr<'a, V>, Self::SQLType: Compatible<R::SQLType> { ... } fn gt<R>(self, other: R) -> SQLExpr<'a, V, Bool, NonNull, Scalar> where R: Expr<'a, V>, Self::SQLType: Compatible<R::SQLType> { ... } fn ge<R>(self, other: R) -> SQLExpr<'a, V, Bool, NonNull, Scalar> where R: Expr<'a, V>, Self::SQLType: Compatible<R::SQLType> { ... } fn lt<R>(self, other: R) -> SQLExpr<'a, V, Bool, NonNull, Scalar> where R: Expr<'a, V>, Self::SQLType: Compatible<R::SQLType> { ... } fn le<R>(self, other: R) -> SQLExpr<'a, V, Bool, NonNull, Scalar> where R: Expr<'a, V>, Self::SQLType: Compatible<R::SQLType> { ... } fn like<R>(self, pattern: R) -> SQLExpr<'a, V, Bool, NonNull, Scalar> where R: Expr<'a, V>, Self::SQLType: Textual, R::SQLType: Textual { ... } fn not_like<R>(self, pattern: R) -> SQLExpr<'a, V, Bool, NonNull, Scalar> where R: Expr<'a, V>, Self::SQLType: Textual, R::SQLType: Textual { ... } fn is_null(self) -> SQLExpr<'a, V, Bool, NonNull, Scalar> { ... } fn is_not_null(self) -> SQLExpr<'a, V, Bool, NonNull, Scalar> { ... } fn between<L, H>( self, low: L, high: H, ) -> SQLExpr<'a, V, Bool, NonNull, Scalar> where L: Expr<'a, V>, H: Expr<'a, V>, Self::SQLType: Compatible<L::SQLType> + Compatible<H::SQLType> { ... } fn not_between<L, H>( self, low: L, high: H, ) -> SQLExpr<'a, V, Bool, NonNull, Scalar> where L: Expr<'a, V>, H: Expr<'a, V>, Self::SQLType: Compatible<L::SQLType> + Compatible<H::SQLType> { ... } fn in_array<I, R>(self, values: I) -> SQLExpr<'a, V, Bool, NonNull, Scalar> where I: IntoIterator<Item = R>, R: Expr<'a, V>, Self::SQLType: Compatible<R::SQLType> { ... } fn not_in_array<I, R>( self, values: I, ) -> SQLExpr<'a, V, Bool, NonNull, Scalar> where I: IntoIterator<Item = R>, R: Expr<'a, V>, Self::SQLType: Compatible<R::SQLType> { ... }
}
Expand description

Extension trait providing method-based comparisons for any Expr type.

This trait is blanket-implemented for all types implementing Expr, allowing method syntax on columns, literals, and expressions:

// Works on columns directly
users.id.eq(42)
users.age.gt(18)

// Chain with operators
users.id.eq(42) & users.age.gt(18)

Provided Methods§

Source

fn eq<R>(self, other: R) -> SQLExpr<'a, V, Bool, NonNull, Scalar>
where R: Expr<'a, V>, Self::SQLType: Compatible<R::SQLType>,

Equality comparison (=).

users.id.eq(42)  // "users"."id" = 42
Source

fn ne<R>(self, other: R) -> SQLExpr<'a, V, Bool, NonNull, Scalar>
where R: Expr<'a, V>, Self::SQLType: Compatible<R::SQLType>,

Inequality comparison (<>).

users.id.ne(42)  // "users"."id" <> 42
Source

fn gt<R>(self, other: R) -> SQLExpr<'a, V, Bool, NonNull, Scalar>
where R: Expr<'a, V>, Self::SQLType: Compatible<R::SQLType>,

Greater-than comparison (>).

users.age.gt(18)  // "users"."age" > 18
Source

fn ge<R>(self, other: R) -> SQLExpr<'a, V, Bool, NonNull, Scalar>
where R: Expr<'a, V>, Self::SQLType: Compatible<R::SQLType>,

Greater-than-or-equal comparison (>=).

users.age.ge(18)  // "users"."age" >= 18
Source

fn lt<R>(self, other: R) -> SQLExpr<'a, V, Bool, NonNull, Scalar>
where R: Expr<'a, V>, Self::SQLType: Compatible<R::SQLType>,

Less-than comparison (<).

users.age.lt(65)  // "users"."age" < 65
Source

fn le<R>(self, other: R) -> SQLExpr<'a, V, Bool, NonNull, Scalar>
where R: Expr<'a, V>, Self::SQLType: Compatible<R::SQLType>,

Less-than-or-equal comparison (<=).

users.age.le(65)  // "users"."age" <= 65
Source

fn like<R>(self, pattern: R) -> SQLExpr<'a, V, Bool, NonNull, Scalar>
where R: Expr<'a, V>, Self::SQLType: Textual, R::SQLType: Textual,

LIKE pattern matching.

users.name.like("%Alice%")  // "users"."name" LIKE '%Alice%'
Source

fn not_like<R>(self, pattern: R) -> SQLExpr<'a, V, Bool, NonNull, Scalar>
where R: Expr<'a, V>, Self::SQLType: Textual, R::SQLType: Textual,

NOT LIKE pattern matching.

users.name.not_like("%Bot%")  // "users"."name" NOT LIKE '%Bot%'
Source

fn is_null(self) -> SQLExpr<'a, V, Bool, NonNull, Scalar>

IS NULL check.

users.deleted_at.is_null()  // "users"."deleted_at" IS NULL
Source

fn is_not_null(self) -> SQLExpr<'a, V, Bool, NonNull, Scalar>

IS NOT NULL check.

users.email.is_not_null()  // "users"."email" IS NOT NULL
Source

fn between<L, H>(self, low: L, high: H) -> SQLExpr<'a, V, Bool, NonNull, Scalar>
where L: Expr<'a, V>, H: Expr<'a, V>, Self::SQLType: Compatible<L::SQLType> + Compatible<H::SQLType>,

BETWEEN comparison.

Checks if the value is between low and high (inclusive).

users.age.between(18, 65)  // ("users"."age" BETWEEN 18 AND 65)
Source

fn not_between<L, H>( self, low: L, high: H, ) -> SQLExpr<'a, V, Bool, NonNull, Scalar>
where L: Expr<'a, V>, H: Expr<'a, V>, Self::SQLType: Compatible<L::SQLType> + Compatible<H::SQLType>,

NOT BETWEEN comparison.

Checks if the value is NOT between low and high.

users.age.not_between(0, 17)  // ("users"."age" NOT BETWEEN 0 AND 17)
Source

fn in_array<I, R>(self, values: I) -> SQLExpr<'a, V, Bool, NonNull, Scalar>
where I: IntoIterator<Item = R>, R: Expr<'a, V>, Self::SQLType: Compatible<R::SQLType>,

IN array check.

Checks if the value is in the provided array.

users.role.in_array([Role::Admin, Role::Moderator])
// "users"."role" IN ('admin', 'moderator')
Source

fn not_in_array<I, R>(self, values: I) -> SQLExpr<'a, V, Bool, NonNull, Scalar>
where I: IntoIterator<Item = R>, R: Expr<'a, V>, Self::SQLType: Compatible<R::SQLType>,

NOT IN array check.

Checks if the value is NOT in the provided array.

users.role.not_in_array([Role::Banned, Role::Suspended])
// "users"."role" NOT IN ('banned', 'suspended')

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<'a, V: SQLParam, E: Expr<'a, V>> ExprExt<'a, V> for E

Blanket implementation for all Expr types.