Expr

Trait Expr 

Source
pub trait Expr<'a, V: SQLParam>: ToSQL<'a, V> {
    type SQLType: DataType;
    type Nullable: Nullability;
    type Aggregate: AggregateKind;
}
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 expression
  • V: The dialect’s value type (SQLiteValue, PostgresValue)

§Associated Types

  • SQLType: The SQL data type this expression evaluates to
  • Nullable: Whether this expression can be NULL
  • Aggregate: 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=Scalar

Required Associated Types§

Source

type SQLType: DataType

The SQL data type this expression evaluates to.

Source

type Nullable: Nullability

Whether this expression can be NULL.

Source

type Aggregate: AggregateKind

Whether this is an aggregate (COUNT, SUM) or scalar expression.

Implementations on Foreign Types§

Source§

impl<'a, V> Expr<'a, V> for &'a str
where V: SQLParam + 'a + From<&'a str> + Into<Cow<'a, V>>,

Source§

impl<'a, V> Expr<'a, V> for bool
where V: SQLParam + 'a + From<bool> + Into<Cow<'a, V>>,

Source§

impl<'a, V> Expr<'a, V> for f32
where V: SQLParam + 'a + From<f32> + Into<Cow<'a, V>>,

Source§

impl<'a, V> Expr<'a, V> for f64
where V: SQLParam + 'a + From<f64> + Into<Cow<'a, V>>,

Source§

impl<'a, V> Expr<'a, V> for i8
where V: SQLParam + 'a + From<i8> + Into<Cow<'a, V>>,

Source§

impl<'a, V> Expr<'a, V> for i16
where V: SQLParam + 'a + From<i16> + Into<Cow<'a, V>>,

Source§

impl<'a, V> Expr<'a, V> for i32
where V: SQLParam + 'a + From<i32> + Into<Cow<'a, V>>,

Source§

impl<'a, V> Expr<'a, V> for i64
where V: SQLParam + 'a + From<i64> + Into<Cow<'a, V>>,

Source§

impl<'a, V> Expr<'a, V> for isize
where V: SQLParam + 'a + From<isize> + Into<Cow<'a, V>>,

Source§

impl<'a, V> Expr<'a, V> for u8
where V: SQLParam + 'a + From<u8> + Into<Cow<'a, V>>,

Source§

impl<'a, V> Expr<'a, V> for u16
where V: SQLParam + 'a + From<u16> + Into<Cow<'a, V>>,

Source§

impl<'a, V> Expr<'a, V> for u32
where V: SQLParam + 'a + From<u32> + Into<Cow<'a, V>>,

Source§

impl<'a, V> Expr<'a, V> for u64
where V: SQLParam + 'a + From<u64> + Into<Cow<'a, V>>,

Source§

impl<'a, V> Expr<'a, V> for usize
where V: SQLParam + 'a + From<usize> + Into<Cow<'a, V>>,

Source§

impl<'a, V> Expr<'a, V> for String
where V: SQLParam + 'a + From<String> + Into<Cow<'a, V>>,

Source§

impl<'a, V, T> Expr<'a, V> for Option<T>
where V: SQLParam + 'a, T: Expr<'a, V>, T::Nullable: Nullability,

Source§

type SQLType = <T as Expr<'a, V>>::SQLType

Source§

type Nullable = Null

Source§

type Aggregate = <T as Expr<'a, V>>::Aggregate

Source§

impl<'a, V, T> Expr<'a, V> for &T
where V: SQLParam + 'a, T: Expr<'a, V>, T::Nullable: Nullability,

Source§

type SQLType = <T as Expr<'a, V>>::SQLType

Source§

type Nullable = <T as Expr<'a, V>>::Nullable

Source§

type Aggregate = <T as Expr<'a, V>>::Aggregate

Implementors§

Source§

impl<'a, V> Expr<'a, V> for SQL<'a, V>
where V: SQLParam + 'a,

Source§

impl<'a, V: SQLParam, T: DataType, N: Nullability, A: AggregateKind> Expr<'a, V> for SQLExpr<'a, V, T, N, A>