pub trait Expr<'a, V: SQLParam>: ToSQL<'a, V> {
type SQLType: DataType;
type Nullable: Nullability;
type Aggregate: AggregateKind;
// Provided methods
fn to_expr_sql(&self) -> SQL<'a, V> { ... }
fn into_expr_sql(self) -> SQL<'a, V>
where Self: Sized { ... }
}Expand description
An expression in SQL with an associated data type.
This is the core trait for type-safe SQL expressions. Every SQL expression (column, literal, function result) implements this with its SQL type.
§Type Parameters
'a: Lifetime of borrowed data in the expressionV: The dialect’s value type (SQLiteValue,PostgresValue)
§Associated Types
SQLType: The SQL data type this expression evaluates toNullable: Whether this expression can be NULLAggregate: Whether this is an aggregate or scalar expression
§Example
use drizzle_core::expr::{Expr, NonNull, Scalar};
use drizzle_core::types::Int;
// i32 literals are Int, NonNull, Scalar
fn check_expr<'a, V, E: Expr<'a, V>>() {}
check_expr::<_, i32>(); // SQLType=Int, Nullable=NonNull, Aggregate=ScalarRequired Associated Types§
Sourcetype Nullable: Nullability
type Nullable: Nullability
Whether this expression can be NULL.
Sourcetype Aggregate: AggregateKind
type Aggregate: AggregateKind
Whether this is an aggregate (COUNT, SUM) or scalar expression.
Provided Methods§
Sourcefn to_expr_sql(&self) -> SQL<'a, V>
fn to_expr_sql(&self) -> SQL<'a, V>
Render this value as a scalar expression by reference.
Most expressions use their ToSQL implementation. A few Rust container
types, notably byte buffers, need expression-specific rendering because
their generic ToSQL form is a comma-separated list.
Sourcefn into_expr_sql(self) -> SQL<'a, V>where
Self: Sized,
fn into_expr_sql(self) -> SQL<'a, V>where
Self: Sized,
Render this value as a scalar expression, consuming it when useful.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".