Skip to main content

ExprExt

Trait ExprExt 

Source
pub trait ExprExt<'a, V: SQLParam>: Expr<'a, V> + Sized {
Show 20 methods // Provided methods fn eq<R>( self, other: R, ) -> SQLExpr<'a, V, <V::DialectMarker as DialectTypes>::Bool, NonNull, <Self::Aggregate as AggOr<<R as ComparisonOperand<'a, V, Self>>::Aggregate>>::Output> where R: ComparisonOperand<'a, V, Self>, Self::SQLType: Compatible<<R as ComparisonOperand<'a, V, Self>>::SQLType>, Self::Aggregate: AggOr<<R as ComparisonOperand<'a, V, Self>>::Aggregate> { ... } fn ne<R>( self, other: R, ) -> SQLExpr<'a, V, <V::DialectMarker as DialectTypes>::Bool, NonNull, <Self::Aggregate as AggOr<<R as ComparisonOperand<'a, V, Self>>::Aggregate>>::Output> where R: ComparisonOperand<'a, V, Self>, Self::SQLType: Compatible<<R as ComparisonOperand<'a, V, Self>>::SQLType>, Self::Aggregate: AggOr<<R as ComparisonOperand<'a, V, Self>>::Aggregate> { ... } fn gt<R>( self, other: R, ) -> SQLExpr<'a, V, <V::DialectMarker as DialectTypes>::Bool, NonNull, <Self::Aggregate as AggOr<<R as ComparisonOperand<'a, V, Self>>::Aggregate>>::Output> where R: ComparisonOperand<'a, V, Self>, Self::SQLType: Compatible<<R as ComparisonOperand<'a, V, Self>>::SQLType>, Self::Aggregate: AggOr<<R as ComparisonOperand<'a, V, Self>>::Aggregate> { ... } fn ge<R>( self, other: R, ) -> SQLExpr<'a, V, <V::DialectMarker as DialectTypes>::Bool, NonNull, <Self::Aggregate as AggOr<<R as ComparisonOperand<'a, V, Self>>::Aggregate>>::Output> where R: ComparisonOperand<'a, V, Self>, Self::SQLType: Compatible<<R as ComparisonOperand<'a, V, Self>>::SQLType>, Self::Aggregate: AggOr<<R as ComparisonOperand<'a, V, Self>>::Aggregate> { ... } fn lt<R>( self, other: R, ) -> SQLExpr<'a, V, <V::DialectMarker as DialectTypes>::Bool, NonNull, <Self::Aggregate as AggOr<<R as ComparisonOperand<'a, V, Self>>::Aggregate>>::Output> where R: ComparisonOperand<'a, V, Self>, Self::SQLType: Compatible<<R as ComparisonOperand<'a, V, Self>>::SQLType>, Self::Aggregate: AggOr<<R as ComparisonOperand<'a, V, Self>>::Aggregate> { ... } fn le<R>( self, other: R, ) -> SQLExpr<'a, V, <V::DialectMarker as DialectTypes>::Bool, NonNull, <Self::Aggregate as AggOr<<R as ComparisonOperand<'a, V, Self>>::Aggregate>>::Output> where R: ComparisonOperand<'a, V, Self>, Self::SQLType: Compatible<<R as ComparisonOperand<'a, V, Self>>::SQLType>, Self::Aggregate: AggOr<<R as ComparisonOperand<'a, V, Self>>::Aggregate> { ... } fn like<R>( self, pattern: R, ) -> SQLExpr<'a, V, <V::DialectMarker as DialectTypes>::Bool, NonNull, <Self::Aggregate as AggOr<<R as ComparisonOperand<'a, V, Self>>::Aggregate>>::Output> where R: ComparisonOperand<'a, V, Self>, Self::SQLType: Compatible<<R as ComparisonOperand<'a, V, Self>>::SQLType> + Textual, <R as ComparisonOperand<'a, V, Self>>::SQLType: Textual, Self::Aggregate: AggOr<<R as ComparisonOperand<'a, V, Self>>::Aggregate> { ... } fn not_like<R>( self, pattern: R, ) -> SQLExpr<'a, V, <V::DialectMarker as DialectTypes>::Bool, NonNull, <Self::Aggregate as AggOr<<R as ComparisonOperand<'a, V, Self>>::Aggregate>>::Output> where R: ComparisonOperand<'a, V, Self>, Self::SQLType: Compatible<<R as ComparisonOperand<'a, V, Self>>::SQLType> + Textual, <R as ComparisonOperand<'a, V, Self>>::SQLType: Textual, Self::Aggregate: AggOr<<R as ComparisonOperand<'a, V, Self>>::Aggregate> { ... } fn is_null( self, ) -> SQLExpr<'a, V, <V::DialectMarker as DialectTypes>::Bool, NonNull, Self::Aggregate> { ... } fn is_not_null( self, ) -> SQLExpr<'a, V, <V::DialectMarker as DialectTypes>::Bool, NonNull, Self::Aggregate> { ... } fn between<L, H>( self, low: L, high: H, ) -> SQLExpr<'a, V, <V::DialectMarker as DialectTypes>::Bool, NonNull, <<Self::Aggregate as AggOr<<L as ComparisonOperand<'a, V, Self>>::Aggregate>>::Output as AggOr<<H as ComparisonOperand<'a, V, Self>>::Aggregate>>::Output> where L: ComparisonOperand<'a, V, Self>, H: ComparisonOperand<'a, V, Self>, Self::SQLType: Compatible<<L as ComparisonOperand<'a, V, Self>>::SQLType> + Compatible<<H as ComparisonOperand<'a, V, Self>>::SQLType>, Self::Aggregate: AggOr<<L as ComparisonOperand<'a, V, Self>>::Aggregate>, <Self::Aggregate as AggOr<<L as ComparisonOperand<'a, V, Self>>::Aggregate>>::Output: AggOr<<H as ComparisonOperand<'a, V, Self>>::Aggregate> { ... } fn not_between<L, H>( self, low: L, high: H, ) -> SQLExpr<'a, V, <V::DialectMarker as DialectTypes>::Bool, NonNull, <<Self::Aggregate as AggOr<<L as ComparisonOperand<'a, V, Self>>::Aggregate>>::Output as AggOr<<H as ComparisonOperand<'a, V, Self>>::Aggregate>>::Output> where L: ComparisonOperand<'a, V, Self>, H: ComparisonOperand<'a, V, Self>, Self::SQLType: Compatible<<L as ComparisonOperand<'a, V, Self>>::SQLType> + Compatible<<H as ComparisonOperand<'a, V, Self>>::SQLType>, Self::Aggregate: AggOr<<L as ComparisonOperand<'a, V, Self>>::Aggregate>, <Self::Aggregate as AggOr<<L as ComparisonOperand<'a, V, Self>>::Aggregate>>::Output: AggOr<<H as ComparisonOperand<'a, V, Self>>::Aggregate> { ... } fn in_array<I, R>( self, values: I, ) -> SQLExpr<'a, V, <V::DialectMarker as DialectTypes>::Bool, NonNull, Self::Aggregate> 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, <V::DialectMarker as DialectTypes>::Bool, NonNull, Self::Aggregate> where I: IntoIterator<Item = R>, R: Expr<'a, V>, Self::SQLType: Compatible<R::SQLType> { ... } fn in_subquery<S>( self, subquery: S, ) -> SQLExpr<'a, V, <V::DialectMarker as DialectTypes>::Bool, NonNull, Self::Aggregate> where S: Expr<'a, V>, Self::SQLType: Compatible<S::SQLType> { ... } fn not_in_subquery<S>( self, subquery: S, ) -> SQLExpr<'a, V, <V::DialectMarker as DialectTypes>::Bool, NonNull, Self::Aggregate> where S: Expr<'a, V>, Self::SQLType: Compatible<S::SQLType> { ... } fn is_distinct_from<R>( self, other: R, ) -> SQLExpr<'a, V, <V::DialectMarker as DialectTypes>::Bool, NonNull, <Self::Aggregate as AggOr<<R as ComparisonOperand<'a, V, Self>>::Aggregate>>::Output> where R: ComparisonOperand<'a, V, Self>, Self::SQLType: Compatible<<R as ComparisonOperand<'a, V, Self>>::SQLType>, Self::Aggregate: AggOr<<R as ComparisonOperand<'a, V, Self>>::Aggregate> { ... } fn is_not_distinct_from<R>( self, other: R, ) -> SQLExpr<'a, V, <V::DialectMarker as DialectTypes>::Bool, NonNull, <Self::Aggregate as AggOr<<R as ComparisonOperand<'a, V, Self>>::Aggregate>>::Output> where R: ComparisonOperand<'a, V, Self>, Self::SQLType: Compatible<<R as ComparisonOperand<'a, V, Self>>::SQLType>, Self::Aggregate: AggOr<<R as ComparisonOperand<'a, V, Self>>::Aggregate> { ... } fn is_true( self, ) -> SQLExpr<'a, V, <V::DialectMarker as DialectTypes>::Bool, NonNull, Self::Aggregate> { ... } fn is_false( self, ) -> SQLExpr<'a, V, <V::DialectMarker as DialectTypes>::Bool, NonNull, Self::Aggregate> { ... }
}
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, <V::DialectMarker as DialectTypes>::Bool, NonNull, <Self::Aggregate as AggOr<<R as ComparisonOperand<'a, V, Self>>::Aggregate>>::Output>
where R: ComparisonOperand<'a, V, Self>, Self::SQLType: Compatible<<R as ComparisonOperand<'a, V, Self>>::SQLType>, Self::Aggregate: AggOr<<R as ComparisonOperand<'a, V, Self>>::Aggregate>,

Equality comparison (=).

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

fn ne<R>( self, other: R, ) -> SQLExpr<'a, V, <V::DialectMarker as DialectTypes>::Bool, NonNull, <Self::Aggregate as AggOr<<R as ComparisonOperand<'a, V, Self>>::Aggregate>>::Output>
where R: ComparisonOperand<'a, V, Self>, Self::SQLType: Compatible<<R as ComparisonOperand<'a, V, Self>>::SQLType>, Self::Aggregate: AggOr<<R as ComparisonOperand<'a, V, Self>>::Aggregate>,

Inequality comparison (<>).

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

fn gt<R>( self, other: R, ) -> SQLExpr<'a, V, <V::DialectMarker as DialectTypes>::Bool, NonNull, <Self::Aggregate as AggOr<<R as ComparisonOperand<'a, V, Self>>::Aggregate>>::Output>
where R: ComparisonOperand<'a, V, Self>, Self::SQLType: Compatible<<R as ComparisonOperand<'a, V, Self>>::SQLType>, Self::Aggregate: AggOr<<R as ComparisonOperand<'a, V, Self>>::Aggregate>,

Greater-than comparison (>).

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

fn ge<R>( self, other: R, ) -> SQLExpr<'a, V, <V::DialectMarker as DialectTypes>::Bool, NonNull, <Self::Aggregate as AggOr<<R as ComparisonOperand<'a, V, Self>>::Aggregate>>::Output>
where R: ComparisonOperand<'a, V, Self>, Self::SQLType: Compatible<<R as ComparisonOperand<'a, V, Self>>::SQLType>, Self::Aggregate: AggOr<<R as ComparisonOperand<'a, V, Self>>::Aggregate>,

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

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

fn lt<R>( self, other: R, ) -> SQLExpr<'a, V, <V::DialectMarker as DialectTypes>::Bool, NonNull, <Self::Aggregate as AggOr<<R as ComparisonOperand<'a, V, Self>>::Aggregate>>::Output>
where R: ComparisonOperand<'a, V, Self>, Self::SQLType: Compatible<<R as ComparisonOperand<'a, V, Self>>::SQLType>, Self::Aggregate: AggOr<<R as ComparisonOperand<'a, V, Self>>::Aggregate>,

Less-than comparison (<).

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

fn le<R>( self, other: R, ) -> SQLExpr<'a, V, <V::DialectMarker as DialectTypes>::Bool, NonNull, <Self::Aggregate as AggOr<<R as ComparisonOperand<'a, V, Self>>::Aggregate>>::Output>
where R: ComparisonOperand<'a, V, Self>, Self::SQLType: Compatible<<R as ComparisonOperand<'a, V, Self>>::SQLType>, Self::Aggregate: AggOr<<R as ComparisonOperand<'a, V, Self>>::Aggregate>,

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

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

fn like<R>( self, pattern: R, ) -> SQLExpr<'a, V, <V::DialectMarker as DialectTypes>::Bool, NonNull, <Self::Aggregate as AggOr<<R as ComparisonOperand<'a, V, Self>>::Aggregate>>::Output>
where R: ComparisonOperand<'a, V, Self>, Self::SQLType: Compatible<<R as ComparisonOperand<'a, V, Self>>::SQLType> + Textual, <R as ComparisonOperand<'a, V, Self>>::SQLType: Textual, Self::Aggregate: AggOr<<R as ComparisonOperand<'a, V, Self>>::Aggregate>,

LIKE pattern matching.

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

fn not_like<R>( self, pattern: R, ) -> SQLExpr<'a, V, <V::DialectMarker as DialectTypes>::Bool, NonNull, <Self::Aggregate as AggOr<<R as ComparisonOperand<'a, V, Self>>::Aggregate>>::Output>
where R: ComparisonOperand<'a, V, Self>, Self::SQLType: Compatible<<R as ComparisonOperand<'a, V, Self>>::SQLType> + Textual, <R as ComparisonOperand<'a, V, Self>>::SQLType: Textual, Self::Aggregate: AggOr<<R as ComparisonOperand<'a, V, Self>>::Aggregate>,

NOT LIKE pattern matching.

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

fn is_null( self, ) -> SQLExpr<'a, V, <V::DialectMarker as DialectTypes>::Bool, NonNull, Self::Aggregate>

IS NULL check.

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

fn is_not_null( self, ) -> SQLExpr<'a, V, <V::DialectMarker as DialectTypes>::Bool, NonNull, Self::Aggregate>

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, <V::DialectMarker as DialectTypes>::Bool, NonNull, <<Self::Aggregate as AggOr<<L as ComparisonOperand<'a, V, Self>>::Aggregate>>::Output as AggOr<<H as ComparisonOperand<'a, V, Self>>::Aggregate>>::Output>
where L: ComparisonOperand<'a, V, Self>, H: ComparisonOperand<'a, V, Self>, Self::SQLType: Compatible<<L as ComparisonOperand<'a, V, Self>>::SQLType> + Compatible<<H as ComparisonOperand<'a, V, Self>>::SQLType>, Self::Aggregate: AggOr<<L as ComparisonOperand<'a, V, Self>>::Aggregate>, <Self::Aggregate as AggOr<<L as ComparisonOperand<'a, V, Self>>::Aggregate>>::Output: AggOr<<H as ComparisonOperand<'a, V, Self>>::Aggregate>,

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, <V::DialectMarker as DialectTypes>::Bool, NonNull, <<Self::Aggregate as AggOr<<L as ComparisonOperand<'a, V, Self>>::Aggregate>>::Output as AggOr<<H as ComparisonOperand<'a, V, Self>>::Aggregate>>::Output>
where L: ComparisonOperand<'a, V, Self>, H: ComparisonOperand<'a, V, Self>, Self::SQLType: Compatible<<L as ComparisonOperand<'a, V, Self>>::SQLType> + Compatible<<H as ComparisonOperand<'a, V, Self>>::SQLType>, Self::Aggregate: AggOr<<L as ComparisonOperand<'a, V, Self>>::Aggregate>, <Self::Aggregate as AggOr<<L as ComparisonOperand<'a, V, Self>>::Aggregate>>::Output: AggOr<<H as ComparisonOperand<'a, V, Self>>::Aggregate>,

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, <V::DialectMarker as DialectTypes>::Bool, NonNull, Self::Aggregate>
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, <V::DialectMarker as DialectTypes>::Bool, NonNull, Self::Aggregate>
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')
Source

fn in_subquery<S>( self, subquery: S, ) -> SQLExpr<'a, V, <V::DialectMarker as DialectTypes>::Bool, NonNull, Self::Aggregate>
where S: Expr<'a, V>, Self::SQLType: Compatible<S::SQLType>,

IN subquery check.

Source

fn not_in_subquery<S>( self, subquery: S, ) -> SQLExpr<'a, V, <V::DialectMarker as DialectTypes>::Bool, NonNull, Self::Aggregate>
where S: Expr<'a, V>, Self::SQLType: Compatible<S::SQLType>,

NOT IN subquery check.

Source

fn is_distinct_from<R>( self, other: R, ) -> SQLExpr<'a, V, <V::DialectMarker as DialectTypes>::Bool, NonNull, <Self::Aggregate as AggOr<<R as ComparisonOperand<'a, V, Self>>::Aggregate>>::Output>
where R: ComparisonOperand<'a, V, Self>, Self::SQLType: Compatible<<R as ComparisonOperand<'a, V, Self>>::SQLType>, Self::Aggregate: AggOr<<R as ComparisonOperand<'a, V, Self>>::Aggregate>,

IS DISTINCT FROM - NULL-safe inequality comparison.

users.status.is_distinct_from("active")
// "users"."status" IS DISTINCT FROM 'active'
Source

fn is_not_distinct_from<R>( self, other: R, ) -> SQLExpr<'a, V, <V::DialectMarker as DialectTypes>::Bool, NonNull, <Self::Aggregate as AggOr<<R as ComparisonOperand<'a, V, Self>>::Aggregate>>::Output>
where R: ComparisonOperand<'a, V, Self>, Self::SQLType: Compatible<<R as ComparisonOperand<'a, V, Self>>::SQLType>, Self::Aggregate: AggOr<<R as ComparisonOperand<'a, V, Self>>::Aggregate>,

IS NOT DISTINCT FROM - NULL-safe equality comparison.

users.status.is_not_distinct_from("active")
// "users"."status" IS NOT DISTINCT FROM 'active'
Source

fn is_true( self, ) -> SQLExpr<'a, V, <V::DialectMarker as DialectTypes>::Bool, NonNull, Self::Aggregate>

IS TRUE - boolean test that handles NULL.

users.is_active.is_true()
// "users"."is_active" IS TRUE
Source

fn is_false( self, ) -> SQLExpr<'a, V, <V::DialectMarker as DialectTypes>::Bool, NonNull, Self::Aggregate>

IS FALSE - boolean test that handles NULL.

users.is_active.is_false()
// "users"."is_active" IS FALSE

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

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

Blanket implementation for all Expr types.