Skip to main content

SelectBuilder

Type Alias SelectBuilder 

Source
pub type SelectBuilder<'a, Schema, State, Table = (), Marker = (), Row = (), Grouped = ()> = QueryBuilder<'a, Schema, State, Table, Marker, Row, Grouped>;
Expand description

Builds a SELECT query specifically for PostgreSQL

Aliased Type§

pub struct SelectBuilder<'a, Schema, State, Table = (), Marker = (), Row = (), Grouped = ()> {
    pub sql: SQL<'a, PostgresValue<'a>>,
    /* private fields */
}

Fields§

§sql: SQL<'a, PostgresValue<'a>>

Implementations§

Source§

impl<'a, S, M> SelectBuilder<'a, S, SelectInitial, (), M>

Source

pub fn from<T>( self, query: T, ) -> SelectBuilder<'a, S, SelectFromSet, T, Scoped<M, Cons<T, Nil>>, <M as ResolveRow<T>>::Row>
where T: ToSQL<'a, PostgresValue<'a>>, M: ResolveRow<T>,

Specifies the table to select FROM and transitions state.

Source§

impl<'a, S, State, T, M, R, G> SelectBuilder<'a, S, State, T, M, R, G>
where State: JoinAllowed,

Source

pub fn join<J: JoinArg<'a, T>>( self, arg: J, ) -> SelectBuilder<'a, S, SelectJoinSet, J::JoinedTable, <M as ScopePush<J::JoinedTable>>::Out, <M as AfterJoin<R, J::JoinedTable>>::NewRow, G>

Adds an INNER JOIN clause to the query.

Source

pub fn natural_join<J: JoinArg<'a, T>>( self, arg: J, ) -> SelectBuilder<'a, S, SelectJoinSet, J::JoinedTable, <M as ScopePush<J::JoinedTable>>::Out, <M as AfterJoin<R, J::JoinedTable>>::NewRow, G>

JOIN with ON clause

Source

pub fn natural_left_join<J: JoinArg<'a, T>>( self, arg: J, ) -> SelectBuilder<'a, S, SelectJoinSet, J::JoinedTable, <M as ScopePush<J::JoinedTable>>::Out, <M as AfterLeftJoin<R, J::JoinedTable>>::NewRow, G>

JOIN with ON clause

Source

pub fn left_join<J: JoinArg<'a, T>>( self, arg: J, ) -> SelectBuilder<'a, S, SelectJoinSet, J::JoinedTable, <M as ScopePush<J::JoinedTable>>::Out, <M as AfterLeftJoin<R, J::JoinedTable>>::NewRow, G>

JOIN with ON clause

Source

pub fn left_outer_join<J: JoinArg<'a, T>>( self, arg: J, ) -> SelectBuilder<'a, S, SelectJoinSet, J::JoinedTable, <M as ScopePush<J::JoinedTable>>::Out, <M as AfterLeftJoin<R, J::JoinedTable>>::NewRow, G>

JOIN with ON clause

Source

pub fn natural_left_outer_join<J: JoinArg<'a, T>>( self, arg: J, ) -> SelectBuilder<'a, S, SelectJoinSet, J::JoinedTable, <M as ScopePush<J::JoinedTable>>::Out, <M as AfterLeftJoin<R, J::JoinedTable>>::NewRow, G>

JOIN with ON clause

Source

pub fn natural_right_join<J: JoinArg<'a, T>>( self, arg: J, ) -> SelectBuilder<'a, S, SelectJoinSet, J::JoinedTable, <M as ScopePush<J::JoinedTable>>::Out, <M as AfterRightJoin<R, J::JoinedTable>>::NewRow, G>

JOIN with ON clause

Source

pub fn right_join<J: JoinArg<'a, T>>( self, arg: J, ) -> SelectBuilder<'a, S, SelectJoinSet, J::JoinedTable, <M as ScopePush<J::JoinedTable>>::Out, <M as AfterRightJoin<R, J::JoinedTable>>::NewRow, G>

JOIN with ON clause

Source

pub fn right_outer_join<J: JoinArg<'a, T>>( self, arg: J, ) -> SelectBuilder<'a, S, SelectJoinSet, J::JoinedTable, <M as ScopePush<J::JoinedTable>>::Out, <M as AfterRightJoin<R, J::JoinedTable>>::NewRow, G>

JOIN with ON clause

Source

pub fn natural_right_outer_join<J: JoinArg<'a, T>>( self, arg: J, ) -> SelectBuilder<'a, S, SelectJoinSet, J::JoinedTable, <M as ScopePush<J::JoinedTable>>::Out, <M as AfterRightJoin<R, J::JoinedTable>>::NewRow, G>

JOIN with ON clause

Source

pub fn natural_full_join<J: JoinArg<'a, T>>( self, arg: J, ) -> SelectBuilder<'a, S, SelectJoinSet, J::JoinedTable, <M as ScopePush<J::JoinedTable>>::Out, <M as AfterFullJoin<R, J::JoinedTable>>::NewRow, G>

JOIN with ON clause

Source

pub fn full_join<J: JoinArg<'a, T>>( self, arg: J, ) -> SelectBuilder<'a, S, SelectJoinSet, J::JoinedTable, <M as ScopePush<J::JoinedTable>>::Out, <M as AfterFullJoin<R, J::JoinedTable>>::NewRow, G>

JOIN with ON clause

Source

pub fn full_outer_join<J: JoinArg<'a, T>>( self, arg: J, ) -> SelectBuilder<'a, S, SelectJoinSet, J::JoinedTable, <M as ScopePush<J::JoinedTable>>::Out, <M as AfterFullJoin<R, J::JoinedTable>>::NewRow, G>

JOIN with ON clause

Source

pub fn natural_full_outer_join<J: JoinArg<'a, T>>( self, arg: J, ) -> SelectBuilder<'a, S, SelectJoinSet, J::JoinedTable, <M as ScopePush<J::JoinedTable>>::Out, <M as AfterFullJoin<R, J::JoinedTable>>::NewRow, G>

JOIN with ON clause

Source

pub fn inner_join<J: JoinArg<'a, T>>( self, arg: J, ) -> SelectBuilder<'a, S, SelectJoinSet, J::JoinedTable, <M as ScopePush<J::JoinedTable>>::Out, <M as AfterJoin<R, J::JoinedTable>>::NewRow, G>

JOIN with ON clause

Source

pub fn cross_join<J: JoinArg<'a, T>>( self, arg: J, ) -> SelectBuilder<'a, S, SelectJoinSet, J::JoinedTable, <M as ScopePush<J::JoinedTable>>::Out, <M as AfterJoin<R, J::JoinedTable>>::NewRow, G>

JOIN with ON clause

Source

pub fn left_join_using<U: PostgresTable<'a>>( self, table: U, columns: impl ToSQL<'a, PostgresValue<'a>>, ) -> SelectBuilder<'a, S, SelectJoinSet, U, <M as ScopePush<U>>::Out, <M as AfterLeftJoin<R, U>>::NewRow, G>
where M: AfterLeftJoin<R, U> + ScopePush<U>,

JOIN with USING clause (PostgreSQL-specific)

Source

pub fn left_outer_join_using<U: PostgresTable<'a>>( self, table: U, columns: impl ToSQL<'a, PostgresValue<'a>>, ) -> SelectBuilder<'a, S, SelectJoinSet, U, <M as ScopePush<U>>::Out, <M as AfterLeftJoin<R, U>>::NewRow, G>
where M: AfterLeftJoin<R, U> + ScopePush<U>,

JOIN with USING clause (PostgreSQL-specific)

Source

pub fn right_join_using<U: PostgresTable<'a>>( self, table: U, columns: impl ToSQL<'a, PostgresValue<'a>>, ) -> SelectBuilder<'a, S, SelectJoinSet, U, <M as ScopePush<U>>::Out, <M as AfterRightJoin<R, U>>::NewRow, G>
where M: AfterRightJoin<R, U> + ScopePush<U>,

JOIN with USING clause (PostgreSQL-specific)

Source

pub fn right_outer_join_using<U: PostgresTable<'a>>( self, table: U, columns: impl ToSQL<'a, PostgresValue<'a>>, ) -> SelectBuilder<'a, S, SelectJoinSet, U, <M as ScopePush<U>>::Out, <M as AfterRightJoin<R, U>>::NewRow, G>
where M: AfterRightJoin<R, U> + ScopePush<U>,

JOIN with USING clause (PostgreSQL-specific)

Source

pub fn full_join_using<U: PostgresTable<'a>>( self, table: U, columns: impl ToSQL<'a, PostgresValue<'a>>, ) -> SelectBuilder<'a, S, SelectJoinSet, U, <M as ScopePush<U>>::Out, <M as AfterFullJoin<R, U>>::NewRow, G>
where M: AfterFullJoin<R, U> + ScopePush<U>,

JOIN with USING clause (PostgreSQL-specific)

Source

pub fn full_outer_join_using<U: PostgresTable<'a>>( self, table: U, columns: impl ToSQL<'a, PostgresValue<'a>>, ) -> SelectBuilder<'a, S, SelectJoinSet, U, <M as ScopePush<U>>::Out, <M as AfterFullJoin<R, U>>::NewRow, G>
where M: AfterFullJoin<R, U> + ScopePush<U>,

JOIN with USING clause (PostgreSQL-specific)

Source

pub fn inner_join_using<U: PostgresTable<'a>>( self, table: U, columns: impl ToSQL<'a, PostgresValue<'a>>, ) -> SelectBuilder<'a, S, SelectJoinSet, U, <M as ScopePush<U>>::Out, <M as AfterJoin<R, U>>::NewRow, G>
where M: AfterJoin<R, U> + ScopePush<U>,

JOIN with USING clause (PostgreSQL-specific)

Source

pub fn join_using<U: PostgresTable<'a>>( self, table: U, columns: impl ToSQL<'a, PostgresValue<'a>>, ) -> SelectBuilder<'a, S, SelectJoinSet, U, <M as ScopePush<U>>::Out, <M as AfterJoin<R, U>>::NewRow, G>
where M: AfterJoin<R, U> + ScopePush<U>,

JOIN with USING clause (PostgreSQL-specific)

Source§

impl<'a, S, State, T, M, R, G> SelectBuilder<'a, S, State, T, M, R, G>
where State: WhereAllowed,

Source

pub fn where<E>( self, condition: E, ) -> SelectBuilder<'a, S, SelectWhereSet, T, M, R, G>
where E: Expr<'a, PostgresValue<'a>>, E::SQLType: BooleanLike,

Adds a WHERE clause to filter query results.

Source§

impl<'a, S, State, T, M, R, G> SelectBuilder<'a, S, State, T, M, R, G>
where State: GroupByAllowed,

Source

pub fn group_by<Gr>( self, columns: Gr, ) -> SelectBuilder<'a, S, SelectGroupSet, T, M, R, Gr::Columns>
where Gr: IntoGroupBy<'a, PostgresValue<'a>>,

Adds a GROUP BY clause to the query.

Source§

impl<'a, S, State, T, M, R, G> SelectBuilder<'a, S, State, T, M, R, G>
where State: HavingAllowed,

Source

pub fn having<E>( self, condition: E, ) -> SelectBuilder<'a, S, SelectGroupSet, T, M, R, G>
where E: Expr<'a, PostgresValue<'a>>, E::SQLType: BooleanLike,

Adds a HAVING clause after GROUP BY.

Source§

impl<'a, S, State, T, M, R, G> SelectBuilder<'a, S, State, T, M, R, G>
where State: OrderByAllowed,

Source

pub fn order_by<TOrderBy>( self, expressions: TOrderBy, ) -> SelectBuilder<'a, S, SelectOrderSet, T, M, R, G>
where TOrderBy: ToSQL<'a, PostgresValue<'a>>,

Sorts the query results.

Source§

impl<'a, S, State, T, M, R, G> SelectBuilder<'a, S, State, T, M, R, G>
where State: LimitAllowed,

Source

pub fn limit( self, limit: usize, ) -> SelectBuilder<'a, S, SelectLimitSet, T, M, R, G>

Limits the number of rows returned.

Source§

impl<'a, S, State, T, M, R, G> SelectBuilder<'a, S, State, T, M, R, G>
where State: OffsetAllowed,

Source

pub fn offset( self, offset: usize, ) -> SelectBuilder<'a, S, SelectOffsetSet, T, M, R, G>

Sets the offset for the query results.

Source§

impl<'a, S, State, T, M, R, G> SelectBuilder<'a, S, State, T, M, R, G>
where State: AsCteState, T: SQLTable<'a, PostgresSchemaType, PostgresValue<'a>>,

Source

pub fn into_cte<Tag: Tag + 'static>( self, ) -> CTEView<'a, <T as SQLTable<'a, PostgresSchemaType, PostgresValue<'a>>>::Aliased<Tag>, Self>

Converts this SELECT query into a typed CTE using alias tag name.

Source§

impl<'a, S, State, T, M, R, G> SelectBuilder<'a, S, State, T, M, R, G>
where State: ExecutableState,

Source

pub fn union( self, other: impl IntoSelect<'a, S, M, R>, ) -> SelectBuilder<'a, S, SelectSetOpSet, T, M, R, G>

Combines this query with another using UNION.

Source

pub fn union_all( self, other: impl IntoSelect<'a, S, M, R>, ) -> SelectBuilder<'a, S, SelectSetOpSet, T, M, R, G>

Combines this query with another using UNION ALL.

Source

pub fn intersect( self, other: impl IntoSelect<'a, S, M, R>, ) -> SelectBuilder<'a, S, SelectSetOpSet, T, M, R, G>

Combines this query with another using INTERSECT.

Source

pub fn intersect_all( self, other: impl IntoSelect<'a, S, M, R>, ) -> SelectBuilder<'a, S, SelectSetOpSet, T, M, R, G>

Combines this query with another using INTERSECT ALL.

Source

pub fn except( self, other: impl IntoSelect<'a, S, M, R>, ) -> SelectBuilder<'a, S, SelectSetOpSet, T, M, R, G>

Combines this query with another using EXCEPT.

Source

pub fn except_all( self, other: impl IntoSelect<'a, S, M, R>, ) -> SelectBuilder<'a, S, SelectSetOpSet, T, M, R, G>

Combines this query with another using EXCEPT ALL.

Source§

impl<'a, S, State, T, M, R, G> SelectBuilder<'a, S, State, T, M, R, G>
where State: ForLockableState,

Source

pub fn for_update(self) -> SelectBuilder<'a, S, SelectForSet, T, M, R, G>

Adds FOR UPDATE clause to lock selected rows for update.

Source

pub fn for_share(self) -> SelectBuilder<'a, S, SelectForSet, T, M, R, G>

Adds FOR SHARE clause to lock selected rows for shared access.

Source

pub fn for_no_key_update(self) -> SelectBuilder<'a, S, SelectForSet, T, M, R, G>

Adds FOR NO KEY UPDATE clause.

Source

pub fn for_key_share(self) -> SelectBuilder<'a, S, SelectForSet, T, M, R, G>

Adds FOR KEY SHARE clause.

Source

pub fn for_update_of<U: PostgresTable<'a>>( self, table: U, ) -> SelectBuilder<'a, S, SelectForSet, T, M, R, G>

Adds FOR UPDATE OF table clause.

Source

pub fn for_share_of<U: PostgresTable<'a>>( self, table: U, ) -> SelectBuilder<'a, S, SelectForSet, T, M, R, G>

Adds FOR SHARE OF table clause.

Source§

impl<S, T, M, R, G> SelectBuilder<'_, S, SelectForSet, T, M, R, G>

Source

pub fn nowait(self) -> Self

Adds NOWAIT option to fail immediately if rows are locked.

Source

pub fn skip_locked(self) -> Self

Adds SKIP LOCKED option to skip over locked rows.

Trait Implementations§

Source§

impl<'a, S, State, T, M, R, G> Expr<'a, PostgresValue<'a>> for SelectBuilder<'a, S, State, T, M, R, G>
where State: ExecutableState, M: SubqueryType<'a, PostgresValue<'a>>,

Source§

type SQLType = <M as SubqueryType<'a, PostgresValue<'a>>>::SQLType

The SQL data type this expression evaluates to.
Source§

type Nullable = Null

Whether this expression can be NULL.
Source§

type Aggregate = Scalar

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

impl<'a, S, State: ExecutableState, T, M, R, G> IntoSelect<'a, S, M, R> for SelectBuilder<'a, S, State, T, M, R, G>

Source§

type State = State

Source§

type Table = T

Source§

fn into_select(self) -> SelectBuilder<'a, S, State, T, M, R>