Trait diesel::expression::AsExpression

source ·
pub trait AsExpression<T>{
    type Expression: Expression<SqlType = T>;

    // Required method
    fn as_expression(self) -> Self::Expression;
}
Expand description

Converts a type to its representation for use in Diesel’s query builder.

This trait is used directly. Apps should typically use IntoSql instead.

Implementations of this trait will generally do one of 3 things:

  • Return self for types which are already parts of Diesel’s query builder

  • Perform some implicit coercion (for example, allowing now to be used as both Timestamp and Timestamptz.

  • Indicate that the type has data which will be sent separately from the query. This is generally referred as a “bind parameter”. Types which implement ToSql will generally implement AsExpression this way.

This trait could be derived

Required Associated Types§

source

type Expression: Expression<SqlType = T>

The expression being returned

Required Methods§

source

fn as_expression(self) -> Self::Expression

Perform the conversion

Implementations on Foreign Types§

source§

impl AsExpression<BigInt> for i64

source§

impl AsExpression<Binary> for Vec<u8>

source§

impl AsExpression<Bool> for bool

source§

impl AsExpression<Date> for String

source§

impl AsExpression<Double> for f64

source§

impl AsExpression<Float> for f32

source§

impl AsExpression<Integer> for i32

source§

impl AsExpression<Nullable<BigInt>> for i64

source§

impl AsExpression<Nullable<Binary>> for Vec<u8>

source§

impl AsExpression<Nullable<Bool>> for bool

source§

impl AsExpression<Nullable<Date>> for String

source§

impl AsExpression<Nullable<Double>> for f64

source§

impl AsExpression<Nullable<Float>> for f32

source§

impl AsExpression<Nullable<Integer>> for i32

source§

impl AsExpression<Nullable<SmallInt>> for i16

source§

impl AsExpression<Nullable<Text>> for String

source§

impl AsExpression<Nullable<Time>> for String

source§

impl AsExpression<Nullable<Timestamp>> for String

source§

impl AsExpression<Nullable<Timestamp>> for SystemTime

source§

impl AsExpression<SmallInt> for i16

source§

impl AsExpression<Text> for String

source§

impl AsExpression<Time> for String

source§

impl AsExpression<Timestamp> for String

source§

impl AsExpression<Timestamp> for SystemTime

source§

impl<'__expr> AsExpression<BigInt> for &'__expr i64

source§

type Expression = Bound<BigInt, &'__expr i64>

source§

fn as_expression(self) -> Self::Expression

source§

impl<'__expr> AsExpression<Binary> for &'__expr Vec<u8>

source§

type Expression = Bound<Binary, &'__expr Vec<u8>>

source§

fn as_expression(self) -> Self::Expression

source§

impl<'__expr> AsExpression<Binary> for &'__expr [u8]

source§

type Expression = Bound<Binary, &'__expr [u8]>

source§

fn as_expression(self) -> Self::Expression

source§

impl<'__expr> AsExpression<Bool> for &'__expr bool

source§

type Expression = Bound<Bool, &'__expr bool>

source§

fn as_expression(self) -> Self::Expression

source§

impl<'__expr> AsExpression<Date> for &'__expr str

source§

type Expression = Bound<Date, &'__expr str>

source§

fn as_expression(self) -> Self::Expression

source§

impl<'__expr> AsExpression<Date> for &'__expr String

source§

type Expression = Bound<Date, &'__expr String>

source§

fn as_expression(self) -> Self::Expression

source§

impl<'__expr> AsExpression<Double> for &'__expr f64

source§

type Expression = Bound<Double, &'__expr f64>

source§

fn as_expression(self) -> Self::Expression

source§

impl<'__expr> AsExpression<Float> for &'__expr f32

source§

type Expression = Bound<Float, &'__expr f32>

source§

fn as_expression(self) -> Self::Expression

source§

impl<'__expr> AsExpression<Integer> for &'__expr i32

source§

type Expression = Bound<Integer, &'__expr i32>

source§

fn as_expression(self) -> Self::Expression

source§

impl<'__expr> AsExpression<Nullable<BigInt>> for &'__expr i64

source§

type Expression = Bound<Nullable<BigInt>, &'__expr i64>

source§

fn as_expression(self) -> Self::Expression

source§

impl<'__expr> AsExpression<Nullable<Binary>> for &'__expr Vec<u8>

source§

type Expression = Bound<Nullable<Binary>, &'__expr Vec<u8>>

source§

fn as_expression(self) -> Self::Expression

source§

impl<'__expr> AsExpression<Nullable<Binary>> for &'__expr [u8]

source§

type Expression = Bound<Nullable<Binary>, &'__expr [u8]>

source§

fn as_expression(self) -> Self::Expression

source§

impl<'__expr> AsExpression<Nullable<Bool>> for &'__expr bool

source§

type Expression = Bound<Nullable<Bool>, &'__expr bool>

source§

fn as_expression(self) -> Self::Expression

source§

impl<'__expr> AsExpression<Nullable<Date>> for &'__expr str

source§

type Expression = Bound<Nullable<Date>, &'__expr str>

source§

fn as_expression(self) -> Self::Expression

source§

impl<'__expr> AsExpression<Nullable<Date>> for &'__expr String

source§

type Expression = Bound<Nullable<Date>, &'__expr String>

source§

fn as_expression(self) -> Self::Expression

source§

impl<'__expr> AsExpression<Nullable<Double>> for &'__expr f64

source§

type Expression = Bound<Nullable<Double>, &'__expr f64>

source§

fn as_expression(self) -> Self::Expression

source§

impl<'__expr> AsExpression<Nullable<Float>> for &'__expr f32

source§

type Expression = Bound<Nullable<Float>, &'__expr f32>

source§

fn as_expression(self) -> Self::Expression

source§

impl<'__expr> AsExpression<Nullable<Integer>> for &'__expr i32

source§

type Expression = Bound<Nullable<Integer>, &'__expr i32>

source§

fn as_expression(self) -> Self::Expression

source§

impl<'__expr> AsExpression<Nullable<SmallInt>> for &'__expr i16

source§

type Expression = Bound<Nullable<SmallInt>, &'__expr i16>

source§

fn as_expression(self) -> Self::Expression

source§

impl<'__expr> AsExpression<Nullable<Text>> for &'__expr str

source§

type Expression = Bound<Nullable<Text>, &'__expr str>

source§

fn as_expression(self) -> Self::Expression

source§

impl<'__expr> AsExpression<Nullable<Text>> for &'__expr String

source§

type Expression = Bound<Nullable<Text>, &'__expr String>

source§

fn as_expression(self) -> Self::Expression

source§

impl<'__expr> AsExpression<Nullable<Time>> for &'__expr str

source§

type Expression = Bound<Nullable<Time>, &'__expr str>

source§

fn as_expression(self) -> Self::Expression

source§

impl<'__expr> AsExpression<Nullable<Time>> for &'__expr String

source§

type Expression = Bound<Nullable<Time>, &'__expr String>

source§

fn as_expression(self) -> Self::Expression

source§

impl<'__expr> AsExpression<Nullable<Timestamp>> for &'__expr str

source§

type Expression = Bound<Nullable<Timestamp>, &'__expr str>

source§

fn as_expression(self) -> Self::Expression

source§

impl<'__expr> AsExpression<Nullable<Timestamp>> for &'__expr String

source§

impl<'__expr> AsExpression<Nullable<Timestamp>> for &'__expr SystemTime

source§

impl<'__expr> AsExpression<SmallInt> for &'__expr i16

source§

type Expression = Bound<SmallInt, &'__expr i16>

source§

fn as_expression(self) -> Self::Expression

source§

impl<'__expr> AsExpression<Text> for &'__expr str

source§

type Expression = Bound<Text, &'__expr str>

source§

fn as_expression(self) -> Self::Expression

source§

impl<'__expr> AsExpression<Text> for &'__expr String

source§

type Expression = Bound<Text, &'__expr String>

source§

fn as_expression(self) -> Self::Expression

source§

impl<'__expr> AsExpression<Time> for &'__expr str

source§

type Expression = Bound<Time, &'__expr str>

source§

fn as_expression(self) -> Self::Expression

source§

impl<'__expr> AsExpression<Time> for &'__expr String

source§

type Expression = Bound<Time, &'__expr String>

source§

fn as_expression(self) -> Self::Expression

source§

impl<'__expr> AsExpression<Timestamp> for &'__expr str

source§

type Expression = Bound<Timestamp, &'__expr str>

source§

fn as_expression(self) -> Self::Expression

source§

impl<'__expr> AsExpression<Timestamp> for &'__expr String

source§

type Expression = Bound<Timestamp, &'__expr String>

source§

fn as_expression(self) -> Self::Expression

source§

impl<'__expr> AsExpression<Timestamp> for &'__expr SystemTime

source§

impl<'__expr, '__expr2> AsExpression<BigInt> for &'__expr2 &'__expr i64

source§

type Expression = Bound<BigInt, &'__expr2 &'__expr i64>

source§

fn as_expression(self) -> Self::Expression

source§

impl<'__expr, '__expr2> AsExpression<Binary> for &'__expr2 &'__expr Vec<u8>

source§

type Expression = Bound<Binary, &'__expr2 &'__expr Vec<u8>>

source§

fn as_expression(self) -> Self::Expression

source§

impl<'__expr, '__expr2> AsExpression<Binary> for &'__expr2 &'__expr [u8]

source§

type Expression = Bound<Binary, &'__expr2 &'__expr [u8]>

source§

fn as_expression(self) -> Self::Expression

source§

impl<'__expr, '__expr2> AsExpression<Bool> for &'__expr2 &'__expr bool

source§

type Expression = Bound<Bool, &'__expr2 &'__expr bool>

source§

fn as_expression(self) -> Self::Expression

source§

impl<'__expr, '__expr2> AsExpression<Date> for &'__expr2 &'__expr str

source§

type Expression = Bound<Date, &'__expr2 &'__expr str>

source§

fn as_expression(self) -> Self::Expression

source§

impl<'__expr, '__expr2> AsExpression<Date> for &'__expr2 &'__expr String

source§

type Expression = Bound<Date, &'__expr2 &'__expr String>

source§

fn as_expression(self) -> Self::Expression

source§

impl<'__expr, '__expr2> AsExpression<Double> for &'__expr2 &'__expr f64

source§

type Expression = Bound<Double, &'__expr2 &'__expr f64>

source§

fn as_expression(self) -> Self::Expression

source§

impl<'__expr, '__expr2> AsExpression<Float> for &'__expr2 &'__expr f32

source§

type Expression = Bound<Float, &'__expr2 &'__expr f32>

source§

fn as_expression(self) -> Self::Expression

source§

impl<'__expr, '__expr2> AsExpression<Integer> for &'__expr2 &'__expr i32

source§

type Expression = Bound<Integer, &'__expr2 &'__expr i32>

source§

fn as_expression(self) -> Self::Expression

source§

impl<'__expr, '__expr2> AsExpression<Nullable<BigInt>> for &'__expr2 &'__expr i64

source§

type Expression = Bound<Nullable<BigInt>, &'__expr2 &'__expr i64>

source§

fn as_expression(self) -> Self::Expression

source§

impl<'__expr, '__expr2> AsExpression<Nullable<Binary>> for &'__expr2 &'__expr Vec<u8>

source§

type Expression = Bound<Nullable<Binary>, &'__expr2 &'__expr Vec<u8>>

source§

fn as_expression(self) -> Self::Expression

source§

impl<'__expr, '__expr2> AsExpression<Nullable<Binary>> for &'__expr2 &'__expr [u8]

source§

type Expression = Bound<Nullable<Binary>, &'__expr2 &'__expr [u8]>

source§

fn as_expression(self) -> Self::Expression

source§

impl<'__expr, '__expr2> AsExpression<Nullable<Bool>> for &'__expr2 &'__expr bool

source§

type Expression = Bound<Nullable<Bool>, &'__expr2 &'__expr bool>

source§

fn as_expression(self) -> Self::Expression

source§

impl<'__expr, '__expr2> AsExpression<Nullable<Date>> for &'__expr2 &'__expr str

source§

type Expression = Bound<Nullable<Date>, &'__expr2 &'__expr str>

source§

fn as_expression(self) -> Self::Expression

source§

impl<'__expr, '__expr2> AsExpression<Nullable<Date>> for &'__expr2 &'__expr String

source§

type Expression = Bound<Nullable<Date>, &'__expr2 &'__expr String>

source§

fn as_expression(self) -> Self::Expression

source§

impl<'__expr, '__expr2> AsExpression<Nullable<Double>> for &'__expr2 &'__expr f64

source§

type Expression = Bound<Nullable<Double>, &'__expr2 &'__expr f64>

source§

fn as_expression(self) -> Self::Expression

source§

impl<'__expr, '__expr2> AsExpression<Nullable<Float>> for &'__expr2 &'__expr f32

source§

type Expression = Bound<Nullable<Float>, &'__expr2 &'__expr f32>

source§

fn as_expression(self) -> Self::Expression

source§

impl<'__expr, '__expr2> AsExpression<Nullable<Integer>> for &'__expr2 &'__expr i32

source§

type Expression = Bound<Nullable<Integer>, &'__expr2 &'__expr i32>

source§

fn as_expression(self) -> Self::Expression

source§

impl<'__expr, '__expr2> AsExpression<Nullable<SmallInt>> for &'__expr2 &'__expr i16

source§

type Expression = Bound<Nullable<SmallInt>, &'__expr2 &'__expr i16>

source§

fn as_expression(self) -> Self::Expression

source§

impl<'__expr, '__expr2> AsExpression<Nullable<Text>> for &'__expr2 &'__expr str

source§

type Expression = Bound<Nullable<Text>, &'__expr2 &'__expr str>

source§

fn as_expression(self) -> Self::Expression

source§

impl<'__expr, '__expr2> AsExpression<Nullable<Text>> for &'__expr2 &'__expr String

source§

type Expression = Bound<Nullable<Text>, &'__expr2 &'__expr String>

source§

fn as_expression(self) -> Self::Expression

source§

impl<'__expr, '__expr2> AsExpression<Nullable<Time>> for &'__expr2 &'__expr str

source§

type Expression = Bound<Nullable<Time>, &'__expr2 &'__expr str>

source§

fn as_expression(self) -> Self::Expression

source§

impl<'__expr, '__expr2> AsExpression<Nullable<Time>> for &'__expr2 &'__expr String

source§

type Expression = Bound<Nullable<Time>, &'__expr2 &'__expr String>

source§

fn as_expression(self) -> Self::Expression

source§

impl<'__expr, '__expr2> AsExpression<Nullable<Timestamp>> for &'__expr2 &'__expr str

source§

type Expression = Bound<Nullable<Timestamp>, &'__expr2 &'__expr str>

source§

fn as_expression(self) -> Self::Expression

source§

impl<'__expr, '__expr2> AsExpression<Nullable<Timestamp>> for &'__expr2 &'__expr String

source§

type Expression = Bound<Nullable<Timestamp>, &'__expr2 &'__expr String>

source§

fn as_expression(self) -> Self::Expression

source§

impl<'__expr, '__expr2> AsExpression<Nullable<Timestamp>> for &'__expr2 &'__expr SystemTime

source§

type Expression = Bound<Nullable<Timestamp>, &'__expr2 &'__expr SystemTime>

source§

fn as_expression(self) -> Self::Expression

source§

impl<'__expr, '__expr2> AsExpression<SmallInt> for &'__expr2 &'__expr i16

source§

type Expression = Bound<SmallInt, &'__expr2 &'__expr i16>

source§

fn as_expression(self) -> Self::Expression

source§

impl<'__expr, '__expr2> AsExpression<Text> for &'__expr2 &'__expr str

source§

type Expression = Bound<Text, &'__expr2 &'__expr str>

source§

fn as_expression(self) -> Self::Expression

source§

impl<'__expr, '__expr2> AsExpression<Text> for &'__expr2 &'__expr String

source§

type Expression = Bound<Text, &'__expr2 &'__expr String>

source§

fn as_expression(self) -> Self::Expression

source§

impl<'__expr, '__expr2> AsExpression<Time> for &'__expr2 &'__expr str

source§

type Expression = Bound<Time, &'__expr2 &'__expr str>

source§

fn as_expression(self) -> Self::Expression

source§

impl<'__expr, '__expr2> AsExpression<Time> for &'__expr2 &'__expr String

source§

type Expression = Bound<Time, &'__expr2 &'__expr String>

source§

fn as_expression(self) -> Self::Expression

source§

impl<'__expr, '__expr2> AsExpression<Timestamp> for &'__expr2 &'__expr str

source§

type Expression = Bound<Timestamp, &'__expr2 &'__expr str>

source§

fn as_expression(self) -> Self::Expression

source§

impl<'__expr, '__expr2> AsExpression<Timestamp> for &'__expr2 &'__expr String

source§

type Expression = Bound<Timestamp, &'__expr2 &'__expr String>

source§

fn as_expression(self) -> Self::Expression

source§

impl<'__expr, '__expr2> AsExpression<Timestamp> for &'__expr2 &'__expr SystemTime

source§

type Expression = Bound<Timestamp, &'__expr2 &'__expr SystemTime>

source§

fn as_expression(self) -> Self::Expression

source§

impl<'__expr, '__expr2, const N: usize> AsExpression<Binary> for &'__expr2 &'__expr [u8; N]

source§

type Expression = Bound<Binary, &'__expr2 &'__expr [u8; N]>

source§

fn as_expression(self) -> Self::Expression

source§

impl<'__expr, '__expr2, const N: usize> AsExpression<Nullable<Binary>> for &'__expr2 &'__expr [u8; N]

source§

type Expression = Bound<Nullable<Binary>, &'__expr2 &'__expr [u8; N]>

source§

fn as_expression(self) -> Self::Expression

source§

impl<'__expr, const N: usize> AsExpression<Binary> for &'__expr [u8; N]

source§

type Expression = Bound<Binary, &'__expr [u8; N]>

source§

fn as_expression(self) -> Self::Expression

source§

impl<'__expr, const N: usize> AsExpression<Nullable<Binary>> for &'__expr [u8; N]

source§

type Expression = Bound<Nullable<Binary>, &'__expr [u8; N]>

source§

fn as_expression(self) -> Self::Expression

source§

impl<'a, 'b, T, ST> AsExpression<ST> for &'b Cow<'a, T>
where T: 'a + ToOwned + ?Sized, Bound<ST, &'b T>: Expression<SqlType = ST>, ST: SqlType + TypedExpressionType,

source§

type Expression = Bound<ST, &'b T>

source§

fn as_expression(self) -> Self::Expression

source§

impl<'a, T, ST> AsExpression<Nullable<ST>> for &'a Option<T>
where ST: SqlType<IsNull = NotNull>, Nullable<ST>: TypedExpressionType,

source§

type Expression = Bound<Nullable<ST>, &'a Option<T>>

source§

fn as_expression(self) -> Self::Expression

source§

impl<'a, T, ST> AsExpression<ST> for Cow<'a, T>
where T: 'a + ToOwned + ?Sized, Bound<ST, Cow<'a, T>>: Expression<SqlType = ST>, ST: SqlType + TypedExpressionType,

source§

type Expression = Bound<ST, Cow<'a, T>>

source§

fn as_expression(self) -> Self::Expression

source§

impl<T, ST> AsExpression<Nullable<ST>> for Option<T>
where ST: SqlType<IsNull = NotNull>, Nullable<ST>: TypedExpressionType,

source§

type Expression = Bound<Nullable<ST>, Option<T>>

source§

fn as_expression(self) -> Self::Expression

source§

impl<const N: usize> AsExpression<Binary> for [u8; N]

source§

type Expression = Bound<Binary, [u8; N]>

source§

fn as_expression(self) -> Self::Expression

source§

impl<const N: usize> AsExpression<Nullable<Binary>> for [u8; N]

Implementors§

source§

impl AsExpression<Nullable<Date>> for today

source§

impl AsExpression<Nullable<Timestamp>> for now

source§

impl AsExpression<Nullable<Timestamptz>> for now

source§

impl AsExpression<Timestamptz> for now

source§

impl<'a> AsExpression<Nullable<Text>> for MigrationVersion<'a>

source§

impl<'a> AsExpression<Text> for MigrationVersion<'a>

source§

impl<'a, '__expr> AsExpression<Nullable<Text>> for &'__expr MigrationVersion<'a>

source§

type Expression = Bound<Nullable<Text>, &'__expr MigrationVersion<'a>>

source§

impl<'a, '__expr> AsExpression<Text> for &'__expr MigrationVersion<'a>

source§

type Expression = Bound<Text, &'__expr MigrationVersion<'a>>

source§

impl<'a, '__expr, '__expr2> AsExpression<Nullable<Text>> for &'__expr2 &'__expr MigrationVersion<'a>

source§

type Expression = Bound<Nullable<Text>, &'__expr2 &'__expr MigrationVersion<'a>>

source§

impl<'a, '__expr, '__expr2> AsExpression<Text> for &'__expr2 &'__expr MigrationVersion<'a>

source§

type Expression = Bound<Text, &'__expr2 &'__expr MigrationVersion<'a>>

source§

impl<T, ST> AsExpression<ST> for T
where T: Expression<SqlType = ST>, ST: SqlType + TypedExpressionType,