pub trait AsQuery {
    type SqlType;
    type Query: Query<SqlType = Self::SqlType>;

    // Required method
    fn as_query(self) -> Self::Query;
}
Expand description

Types that can be converted into a complete, typed SQL query.

This is used internally to automatically add the right select clause when none is specified, or to automatically add RETURNING * in certain contexts.

A type which implements this trait is guaranteed to be valid for execution.

Required Associated Types§

source

type SqlType

The SQL type of Self::Query

source

type Query: Query<SqlType = Self::SqlType>

What kind of query does this type represent?

Required Methods§

source

fn as_query(self) -> Self::Query

Converts a type which semantically represents a SQL query into the actual query being executed. See the trait level docs for more.

Implementors§

source§

impl<S> AsQuery for Alias<S>where S: AliasSource, S::Target: AsQuery, Self: QuerySource, <Self as QuerySource>::DefaultSelection: ValidGrouping<()>,

§

type SqlType = <<Alias<S> as QuerySource>::DefaultSelection as Expression>::SqlType

§

type Query = SelectStatement<FromClause<Alias<S>>, DefaultSelectClause<FromClause<Alias<S>>>, NoDistinctClause, NoWhereClause, NoOrderClause, LimitOffsetClause<NoLimitClause, NoOffsetClause>, NoGroupByClause, NoHavingClause, NoLockingClause>

source§

impl<S> AsQuery for Only<S>where S: Table + Clone, <S as QuerySource>::DefaultSelection: ValidGrouping<()> + SelectableExpression<Only<S>>,

§

type SqlType = <<Only<S> as QuerySource>::DefaultSelection as Expression>::SqlType

§

type Query = SelectStatement<FromClause<Only<S>>, DefaultSelectClause<FromClause<Only<S>>>, NoDistinctClause, NoWhereClause, NoOrderClause, LimitOffsetClause<NoLimitClause, NoOffsetClause>, NoGroupByClause, NoHavingClause, NoLockingClause>

source§

impl<T, U> AsQuery for DeleteStatement<T, U, NoReturningClause>where T: Table, T::AllColumns: SelectableExpression<T>, DeleteStatement<T, U, ReturningClause<T::AllColumns>>: Query,

§

type SqlType = <<DeleteStatement<T, U, NoReturningClause> as AsQuery>::Query as Query>::SqlType

§

type Query = DeleteStatement<T, U, ReturningClause<<T as Table>::AllColumns>>

source§

impl<T, U, Op> AsQuery for InsertStatement<T, U, Op, NoReturningClause>where T: Table, InsertStatement<T, U, Op, ReturningClause<T::AllColumns>>: Query,

§

type SqlType = <<InsertStatement<T, U, Op, NoReturningClause> as AsQuery>::Query as Query>::SqlType

§

type Query = InsertStatement<T, U, Op, ReturningClause<<T as Table>::AllColumns>>

source§

impl<T, U, V> AsQuery for UpdateStatement<T, U, V, NoReturningClause>where T: Table, UpdateStatement<T, U, V, ReturningClause<T::AllColumns>>: Query, T::AllColumns: ValidGrouping<()>, <T::AllColumns as ValidGrouping<()>>::IsAggregate: MixedAggregates<No, Output = No>,

§

type SqlType = <<UpdateStatement<T, U, V, NoReturningClause> as AsQuery>::Query as Query>::SqlType

§

type Query = UpdateStatement<T, U, V, ReturningClause<<T as Table>::AllColumns>>

source§

impl<T: Query> AsQuery for T

§

type SqlType = <T as Query>::SqlType

§

type Query = T