Skip to main content

Select

Struct Select 

Source
pub struct Select { /* private fields */ }
Expand description

A SELECT statement.

Implementations§

Source§

impl Select

Source

pub fn new() -> Self

A new empty select whose conditions default to Condition::all().

Source

pub fn distinct(self) -> Self

Sets SELECT DISTINCT.

Source

pub fn column(self, column: impl Into<ColumnRef>) -> Self

Selects a column.

Source

pub fn columns<C: Into<ColumnRef>>( self, columns: impl IntoIterator<Item = C>, ) -> Self

Selects several columns.

Source

pub fn expr(self, expr: Expr) -> Self

Selects an expression.

Source

pub fn expr_as(self, expr: Expr, alias: impl IntoIden) -> Self

Selects an aliased expression.

Source

pub fn has_items(&self) -> bool

Whether any item has been selected; without one the statement renders SELECT *.

Source

pub fn clear_items(self) -> Self

Removes all selected items.

Source

pub fn from(self, table: impl Into<TableRef>) -> Self

Adds a FROM table.

Source

pub fn from_subquery(self, subquery: Select, alias: impl IntoIden) -> Self

Sets FROM (subquery) AS alias.

Source

pub fn join( self, kind: JoinType, table: impl Into<TableRef>, on: impl IntoCondition, ) -> Self

Adds a JOIN table ON cond of the given kind.

Source

pub fn inner_join( self, table: impl Into<TableRef>, on: impl IntoCondition, ) -> Self

Adds an INNER JOIN.

Source

pub fn left_join( self, table: impl Into<TableRef>, on: impl IntoCondition, ) -> Self

Adds a LEFT JOIN.

Source

pub fn and_where(self, cond: impl IntoCondition) -> Self

Adds a condition to WHERE with AND.

Source

pub fn cond_where(self, cond: impl IntoCondition) -> Self

Replaces the whole WHERE condition.

Source

pub fn group_by(self, expr: Expr) -> Self

Adds a GROUP BY expression.

Source

pub fn and_having(self, cond: impl IntoCondition) -> Self

Adds a condition to HAVING with AND.

Source

pub fn order_by(self, column: impl Into<ColumnRef>, order: Order) -> Self

Adds an ORDER BY column.

Source

pub fn order_by_expr(self, expr: Expr, order: Order) -> Self

Adds an ORDER BY expr.

Source

pub fn clear_order_by(self) -> Self

Removes the ordering.

Source

pub fn limit(self, limit: u64) -> Self

Sets LIMIT.

Source

pub fn reset_limit(self) -> Self

Removes LIMIT.

Source

pub fn offset(self, offset: u64) -> Self

Sets OFFSET.

Source

pub fn reset_offset(self) -> Self

Removes OFFSET.

Source

pub fn from_tables(&self) -> &[TableRef]

The FROM tables.

Source

pub fn joins(&self) -> &[Join]

The join clauses, in order.

Trait Implementations§

Source§

impl Build for Select

Source§

fn to_statement(&self) -> Statement

Renders into a Statement.
Source§

fn build(&self) -> (String, Vec<Value>)

Renders to the SQL text and the values to bind.
Source§

fn to_string_inlined(&self) -> String

Renders with literals inlined, for logs and tests only.
Source§

impl Clone for Select

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Select

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Select

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl PartialEq for Select

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Select

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.