Skip to main content

ExprTrait

Trait ExprTrait 

Source
pub trait ExprTrait: Sized {
Show 34 methods // Required method fn into_simple_expr(self) -> SimpleExpr; // Provided methods fn eq<V>(self, v: V) -> SimpleExpr where V: Into<SimpleExpr> { ... } fn ne<V>(self, v: V) -> SimpleExpr where V: Into<SimpleExpr> { ... } fn lt<V>(self, v: V) -> SimpleExpr where V: Into<SimpleExpr> { ... } fn lte<V>(self, v: V) -> SimpleExpr where V: Into<SimpleExpr> { ... } fn gt<V>(self, v: V) -> SimpleExpr where V: Into<SimpleExpr> { ... } fn gte<V>(self, v: V) -> SimpleExpr where V: Into<SimpleExpr> { ... } fn is_null(self) -> SimpleExpr { ... } fn is_not_null(self) -> SimpleExpr { ... } fn between<A, B>(self, a: A, b: B) -> SimpleExpr where A: Into<SimpleExpr>, B: Into<SimpleExpr> { ... } fn not_between<A, B>(self, a: A, b: B) -> SimpleExpr where A: Into<SimpleExpr>, B: Into<SimpleExpr> { ... } fn is_in<I, V>(self, values: I) -> SimpleExpr where I: IntoIterator<Item = V>, V: Into<SimpleExpr> { ... } fn is_not_in<I, V>(self, values: I) -> SimpleExpr where I: IntoIterator<Item = V>, V: Into<SimpleExpr> { ... } fn like<V>(self, pattern: V) -> SimpleExpr where V: Into<SimpleExpr> { ... } fn not_like<V>(self, pattern: V) -> SimpleExpr where V: Into<SimpleExpr> { ... } fn ilike<V>(self, pattern: V) -> SimpleExpr where V: Into<SimpleExpr> { ... } fn not_ilike<V>(self, pattern: V) -> SimpleExpr where V: Into<SimpleExpr> { ... } fn starts_with<S>(self, prefix: S) -> SimpleExpr where S: Into<String> { ... } fn ends_with<S>(self, suffix: S) -> SimpleExpr where S: Into<String> { ... } fn contains<S>(self, substring: S) -> SimpleExpr where S: Into<String> { ... } fn and<E>(self, other: E) -> SimpleExpr where E: Into<SimpleExpr> { ... } fn or<E>(self, other: E) -> SimpleExpr where E: Into<SimpleExpr> { ... } fn not(self) -> SimpleExpr { ... } fn add<V>(self, v: V) -> SimpleExpr where V: Into<SimpleExpr> { ... } fn sub<V>(self, v: V) -> SimpleExpr where V: Into<SimpleExpr> { ... } fn mul<V>(self, v: V) -> SimpleExpr where V: Into<SimpleExpr> { ... } fn div<V>(self, v: V) -> SimpleExpr where V: Into<SimpleExpr> { ... } fn modulo<V>(self, v: V) -> SimpleExpr where V: Into<SimpleExpr> { ... } fn bit_and<V>(self, v: V) -> SimpleExpr where V: Into<SimpleExpr> { ... } fn bit_or<V>(self, v: V) -> SimpleExpr where V: Into<SimpleExpr> { ... } fn left_shift<V>(self, v: V) -> SimpleExpr where V: Into<SimpleExpr> { ... } fn right_shift<V>(self, v: V) -> SimpleExpr where V: Into<SimpleExpr> { ... } fn cast_as<T>(self, type_name: T) -> SimpleExpr where T: IntoIden { ... } fn as_enum<T>(self, type_name: T) -> SimpleExpr where T: IntoIden { ... }
}
Expand description

Trait for expression operations.

This trait provides methods for building complex expressions through operator chaining. It is implemented for Expr and SimpleExpr.

§Example

use reinhardt_query::{Expr, ExprTrait};

// Comparison
let expr = Expr::col("age").gte(18);

// Logical operations
let expr = Expr::col("active").eq(true).and(Expr::col("verified").eq(true));

// Arithmetic
let expr = Expr::col("price").mul(Expr::col("quantity"));

Required Methods§

Source

fn into_simple_expr(self) -> SimpleExpr

Build the final SimpleExpr.

Provided Methods§

Source

fn eq<V>(self, v: V) -> SimpleExpr
where V: Into<SimpleExpr>,

Equal (=).

§Example
Expr::col("name").eq("Alice")
// Generates: "name" = 'Alice'
Source

fn ne<V>(self, v: V) -> SimpleExpr
where V: Into<SimpleExpr>,

Not equal (<>).

Source

fn lt<V>(self, v: V) -> SimpleExpr
where V: Into<SimpleExpr>,

Less than (<).

Source

fn lte<V>(self, v: V) -> SimpleExpr
where V: Into<SimpleExpr>,

Less than or equal (<=).

Source

fn gt<V>(self, v: V) -> SimpleExpr
where V: Into<SimpleExpr>,

Greater than (>).

Source

fn gte<V>(self, v: V) -> SimpleExpr
where V: Into<SimpleExpr>,

Greater than or equal (>=).

Source

fn is_null(self) -> SimpleExpr

IS NULL.

Source

fn is_not_null(self) -> SimpleExpr

IS NOT NULL.

Source

fn between<A, B>(self, a: A, b: B) -> SimpleExpr
where A: Into<SimpleExpr>, B: Into<SimpleExpr>,

BETWEEN.

§Example
Expr::col("age").between(18, 65)
// Generates: "age" BETWEEN 18 AND 65
Source

fn not_between<A, B>(self, a: A, b: B) -> SimpleExpr
where A: Into<SimpleExpr>, B: Into<SimpleExpr>,

NOT BETWEEN.

Source

fn is_in<I, V>(self, values: I) -> SimpleExpr
where I: IntoIterator<Item = V>, V: Into<SimpleExpr>,

IN.

Returns FALSE when the iterator is empty, since x IN () is invalid SQL.

§Example
Expr::col("status").is_in(["active", "pending"])
// Generates: "status" IN ('active', 'pending')
Source

fn is_not_in<I, V>(self, values: I) -> SimpleExpr
where I: IntoIterator<Item = V>, V: Into<SimpleExpr>,

NOT IN.

Returns TRUE when the iterator is empty, since x NOT IN () is invalid SQL and logically equivalent to TRUE.

Source

fn like<V>(self, pattern: V) -> SimpleExpr
where V: Into<SimpleExpr>,

LIKE.

§Example
Expr::col("name").like("%john%")
// Generates: "name" LIKE '%john%'
Source

fn not_like<V>(self, pattern: V) -> SimpleExpr
where V: Into<SimpleExpr>,

NOT LIKE.

Source

fn ilike<V>(self, pattern: V) -> SimpleExpr
where V: Into<SimpleExpr>,

ILIKE (case-insensitive LIKE, PostgreSQL).

Source

fn not_ilike<V>(self, pattern: V) -> SimpleExpr
where V: Into<SimpleExpr>,

NOT ILIKE (PostgreSQL).

Source

fn starts_with<S>(self, prefix: S) -> SimpleExpr
where S: Into<String>,

Helper for LIKE with prefix wildcard.

SQL wildcard characters (%, _) and the escape character (\) in user input are escaped before constructing the pattern. The generated SQL includes an explicit ESCAPE '\' clause so that the backslash escaping is portable across all backends (including SQLite, which does not treat \ as an escape character by default).

Source

fn ends_with<S>(self, suffix: S) -> SimpleExpr
where S: Into<String>,

Helper for LIKE with suffix wildcard.

SQL wildcard characters (%, _) and the escape character (\) in user input are escaped before constructing the pattern. The generated SQL includes an explicit ESCAPE '\' clause for cross-backend portability.

Source

fn contains<S>(self, substring: S) -> SimpleExpr
where S: Into<String>,

Helper for LIKE with both wildcards.

SQL wildcard characters (%, _) and the escape character (\) in user input are escaped before constructing the pattern. The generated SQL includes an explicit ESCAPE '\' clause for cross-backend portability.

Source

fn and<E>(self, other: E) -> SimpleExpr
where E: Into<SimpleExpr>,

AND.

Source

fn or<E>(self, other: E) -> SimpleExpr
where E: Into<SimpleExpr>,

OR.

Source

fn not(self) -> SimpleExpr

NOT (unary).

Source

fn add<V>(self, v: V) -> SimpleExpr
where V: Into<SimpleExpr>,

Addition (+).

Source

fn sub<V>(self, v: V) -> SimpleExpr
where V: Into<SimpleExpr>,

Subtraction (-).

Source

fn mul<V>(self, v: V) -> SimpleExpr
where V: Into<SimpleExpr>,

Multiplication (*).

Source

fn div<V>(self, v: V) -> SimpleExpr
where V: Into<SimpleExpr>,

Division (/).

Source

fn modulo<V>(self, v: V) -> SimpleExpr
where V: Into<SimpleExpr>,

Modulo (%).

Source

fn bit_and<V>(self, v: V) -> SimpleExpr
where V: Into<SimpleExpr>,

Bitwise AND (&).

Source

fn bit_or<V>(self, v: V) -> SimpleExpr
where V: Into<SimpleExpr>,

Bitwise OR (|).

Source

fn left_shift<V>(self, v: V) -> SimpleExpr
where V: Into<SimpleExpr>,

Left shift (<<).

Source

fn right_shift<V>(self, v: V) -> SimpleExpr
where V: Into<SimpleExpr>,

Right shift (>>).

Source

fn cast_as<T>(self, type_name: T) -> SimpleExpr
where T: IntoIden,

CAST expression.

§Example
Expr::col("age").cast_as("TEXT")
// Generates: CAST("age" AS TEXT)
Source

fn as_enum<T>(self, type_name: T) -> SimpleExpr
where T: IntoIden,

AS ENUM expression (PostgreSQL).

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§