pub trait AsExpression<T>where
    T: SqlType + TypedExpressionType,{
    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<'expr2, 'expr> AsExpression<BigInt> for &'expr2 &'expr i64

§

type Expression = Bound<BigInt, &'expr2 &'expr i64>

source§

fn as_expression(self) -> Self::Expression

source§

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

§

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

source§

fn as_expression(self) -> Self::Expression

source§

impl AsExpression<Nullable<Timestamp>> for SystemTime

source§

impl<'expr2, 'expr> AsExpression<Timestamp> for &'expr2 &'expr SystemTime

§

type Expression = Bound<Timestamp, &'expr2 &'expr SystemTime>

source§

fn as_expression(self) -> Self::Expression

source§

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

§

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

source§

fn as_expression(self) -> Self::Expression

source§

impl AsExpression<SmallInt> for i16

§

type Expression = Bound<SmallInt, i16>

source§

fn as_expression(self) -> Self::Expression

source§

impl AsExpression<Integer> for i32

§

type Expression = Bound<Integer, i32>

source§

fn as_expression(self) -> Self::Expression

source§

impl<'expr2, 'expr> AsExpression<Text> for &'expr2 &'expr str

§

type Expression = Bound<Text, &'expr2 &'expr str>

source§

fn as_expression(self) -> Self::Expression

source§

impl<'expr2, 'expr> AsExpression<Nullable<SmallInt>> for &'expr2 &'expr i16

§

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

source§

fn as_expression(self) -> Self::Expression

source§

impl<'expr2, 'expr> AsExpression<Nullable<Bool>> for &'expr2 &'expr bool

§

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

source§

fn as_expression(self) -> Self::Expression

source§

impl AsExpression<Nullable<BigInt>> for i64

source§

impl<'expr2, 'expr> AsExpression<Nullable<Binary>> for &'expr2 &'expr Vec<u8>

§

type Expression = Bound<Nullable<Binary>, &'expr2 &'expr Vec<u8, Global>>

source§

fn as_expression(self) -> Self::Expression

source§

impl AsExpression<Text> for String

§

type Expression = Bound<Text, String>

source§

fn as_expression(self) -> Self::Expression

source§

impl AsExpression<Double> for f64

§

type Expression = Bound<Double, f64>

source§

fn as_expression(self) -> Self::Expression

source§

impl<'expr2, 'expr> AsExpression<Float> for &'expr2 &'expr f32

§

type Expression = Bound<Float, &'expr2 &'expr f32>

source§

fn as_expression(self) -> Self::Expression

source§

impl AsExpression<BigInt> for i64

§

type Expression = Bound<BigInt, i64>

source§

fn as_expression(self) -> Self::Expression

source§

impl AsExpression<Bool> for bool

§

type Expression = Bound<Bool, bool>

source§

fn as_expression(self) -> Self::Expression

source§

impl<'expr2, 'expr> AsExpression<Nullable<Text>> for &'expr2 &'expr String

§

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

source§

fn as_expression(self) -> Self::Expression

source§

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

§

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

source§

fn as_expression(self) -> Self::Expression

source§

impl AsExpression<Nullable<Double>> for f64

source§

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

§

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

source§

fn as_expression(self) -> Self::Expression

source§

impl<'expr2, 'expr> AsExpression<Double> for &'expr2 &'expr f64

§

type Expression = Bound<Double, &'expr2 &'expr f64>

source§

fn as_expression(self) -> Self::Expression

source§

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

§

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

source§

fn as_expression(self) -> Self::Expression

source§

impl<'expr2, 'expr> AsExpression<Nullable<Integer>> for &'expr2 &'expr i32

§

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

source§

fn as_expression(self) -> Self::Expression

source§

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

§

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

source§

fn as_expression(self) -> Self::Expression

source§

impl AsExpression<Nullable<Text>> for String

source§

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

§

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

source§

fn as_expression(self) -> Self::Expression

source§

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

§

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

source§

fn as_expression(self) -> Self::Expression

source§

impl<'expr2, 'expr> AsExpression<Text> for &'expr2 &'expr String

§

type Expression = Bound<Text, &'expr2 &'expr String>

source§

fn as_expression(self) -> Self::Expression

source§

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

source§

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

§

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

source§

fn as_expression(self) -> Self::Expression

source§

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

§

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

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,

§

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

source§

fn as_expression(self) -> Self::Expression

source§

impl<'expr2, 'expr> AsExpression<Nullable<Binary>> for &'expr2 &'expr [u8]

§

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

source§

fn as_expression(self) -> Self::Expression

source§

impl<'expr2, 'expr> AsExpression<Nullable<Text>> for &'expr2 &'expr str

§

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

source§

fn as_expression(self) -> Self::Expression

source§

impl<'expr2, 'expr> AsExpression<Nullable<Timestamp>> for &'expr2 &'expr SystemTime

§

type Expression = Bound<Nullable<Timestamp>, &'expr2 &'expr SystemTime>

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,

§

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

source§

fn as_expression(self) -> Self::Expression

source§

impl AsExpression<Binary> for Vec<u8>

§

type Expression = Bound<Binary, Vec<u8, Global>>

source§

fn as_expression(self) -> Self::Expression

source§

impl AsExpression<Nullable<Bool>> for bool

source§

impl AsExpression<Nullable<Float>> for f32

source§

impl<'expr2, 'expr> AsExpression<Nullable<Double>> for &'expr2 &'expr f64

§

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

source§

fn as_expression(self) -> Self::Expression

source§

impl<'expr2, 'expr> AsExpression<Integer> for &'expr2 &'expr i32

§

type Expression = Bound<Integer, &'expr2 &'expr i32>

source§

fn as_expression(self) -> Self::Expression

source§

impl AsExpression<Nullable<SmallInt>> for i16

source§

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

§

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

source§

fn as_expression(self) -> Self::Expression

source§

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

§

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

source§

fn as_expression(self) -> Self::Expression

source§

impl AsExpression<Timestamp> for SystemTime

source§

impl<'expr2, 'expr> AsExpression<Nullable<BigInt>> for &'expr2 &'expr i64

§

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

source§

fn as_expression(self) -> Self::Expression

source§

impl<'expr2, 'expr> AsExpression<SmallInt> for &'expr2 &'expr i16

§

type Expression = Bound<SmallInt, &'expr2 &'expr i16>

source§

fn as_expression(self) -> Self::Expression

source§

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

§

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

source§

fn as_expression(self) -> Self::Expression

source§

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

§

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

source§

fn as_expression(self) -> Self::Expression

source§

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

source§

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

§

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

source§

fn as_expression(self) -> Self::Expression

source§

impl<'expr2, 'expr> AsExpression<Bool> for &'expr2 &'expr bool

§

type Expression = Bound<Bool, &'expr2 &'expr bool>

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,

§

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

source§

fn as_expression(self) -> Self::Expression

source§

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

§

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

source§

fn as_expression(self) -> Self::Expression

source§

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

§

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

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,

§

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

source§

fn as_expression(self) -> Self::Expression

source§

impl AsExpression<Nullable<Integer>> for i32

source§

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

§

type Expression = Bound<Timestamp, &'expr SystemTime>

source§

fn as_expression(self) -> Self::Expression

source§

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

§

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

source§

fn as_expression(self) -> Self::Expression

source§

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

§

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

source§

fn as_expression(self) -> Self::Expression

source§

impl AsExpression<Float> for f32

§

type Expression = Bound<Float, f32>

source§

fn as_expression(self) -> Self::Expression

source§

impl<'expr2, 'expr> AsExpression<Binary> for &'expr2 &'expr [u8]

§

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

source§

fn as_expression(self) -> Self::Expression

source§

impl<'expr2, 'expr> AsExpression<Nullable<Float>> for &'expr2 &'expr f32

§

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

source§

fn as_expression(self) -> Self::Expression

source§

impl<'expr2, 'expr> AsExpression<Binary> for &'expr2 &'expr Vec<u8>

§

type Expression = Bound<Binary, &'expr2 &'expr Vec<u8, Global>>

source§

fn as_expression(self) -> Self::Expression

source§

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

§

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

source§

fn as_expression(self) -> Self::Expression

Implementors§

source§

impl AsExpression<Nullable<Date>> for today

§

type Expression = Coerce<today, Nullable<Date>>

source§

impl AsExpression<Nullable<Timestamp>> for now

source§

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

source§

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

source§

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

§

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

source§

impl<'expr2, 'expr, 'a> AsExpression<Text> for &'expr2 &'expr MigrationVersion<'a>

§

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

source§

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

§

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

source§

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

§

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

source§

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

§

type Expression = T