Trait diesel::expression::array_comparison::AsInExpression

source ·
pub trait AsInExpression<T: SqlType + TypedExpressionType> {
    type InExpression: MaybeEmpty + Expression<SqlType = T>;

    // Required method
    fn as_in_expression(self) -> Self::InExpression;
Available on crate feature i-implement-a-third-party-backend-and-opt-into-breaking-changes only.
Expand description

This trait describes how a type is transformed to the IN (values) value expression

Diesel provided several implementations here:

  • An implementation for any Iterator over values that implement AsExpression<ST> for the corresponding sql type ST. The corresponding values clause will contain bind statements for each individual value.
  • An implementation for select statements, that returns a single field. The corresponding values clause will contain the sub query.

This trait is exposed for custom third party backends so that they can restrict the QueryFragment implementations for In and NotIn.

Required Associated Types§


type InExpression: MaybeEmpty + Expression<SqlType = T>

Type of the expression returned by AsInExpression::as_in_expression

Required Methods§


fn as_in_expression(self) -> Self::InExpression

Construct the diesel query dsl representation of the IN (values) clause for the given type



impl<'a, ST, QS, DB, GB> AsInExpression<ST> for BoxedSelectStatement<'a, ST, QS, DB, GB>
where ST: SqlType + TypedExpressionType, Subselect<BoxedSelectStatement<'a, ST, QS, DB, GB>, ST>: Expression<SqlType = ST>,


type InExpression = Subselect<BoxedSelectStatement<'a, ST, QS, DB, GB>, ST>


impl<I, T, ST> AsInExpression<ST> for I
where I: IntoIterator<Item = T>, T: AsExpression<ST>, ST: SqlType + TypedExpressionType,


type InExpression = Many<ST, T>


impl<ST, F, S, D, W, O, LOf, G, H, LC> AsInExpression<ST> for SelectStatement<F, S, D, W, O, LOf, G, H, LC>
where ST: SqlType + TypedExpressionType, Subselect<Self, ST>: Expression<SqlType = ST>, Self: SelectQuery<SqlType = ST>,


type InExpression = Subselect<SelectStatement<F, S, D, W, O, LOf, G, H, LC>, ST>