pub struct SelectBuilder { /* private fields */ }Expand description
Builder for SELECT queries.
Implementations§
Source§impl SelectBuilder
impl SelectBuilder
Sourcepub fn with_capacity(self, capacity: SelectCapacity) -> Self
pub fn with_capacity(self, capacity: SelectCapacity) -> Self
Reserve capacity for the builder’s internal vectors.
Sourcepub fn items(self, items: Vec<SelectItem>) -> Self
pub fn items(self, items: Vec<SelectItem>) -> Self
Sets the select items.
Sourcepub fn item(self, item: SelectItem) -> Self
pub fn item(self, item: SelectItem) -> Self
Adds a select item.
Sourcepub fn computed(self, expr: Expr, alias: impl Into<String>) -> Self
pub fn computed(self, expr: Expr, alias: impl Into<String>) -> Self
Adds a computed expression with an alias.
Sourcepub fn order_by(self, column: impl Into<String>, direction: OrderDir) -> Self
pub fn order_by(self, column: impl Into<String>, direction: OrderDir) -> Self
Adds an ORDER BY clause.
Sourcepub fn order_by_asc(self, column: impl Into<String>) -> Self
pub fn order_by_asc(self, column: impl Into<String>) -> Self
Adds an ORDER BY ASC clause.
Sourcepub fn order_by_desc(self, column: impl Into<String>) -> Self
pub fn order_by_desc(self, column: impl Into<String>) -> Self
Adds an ORDER BY DESC clause.
Sourcepub fn take(self, n: i32) -> Self
pub fn take(self, n: i32) -> Self
Sets the row count (maps to SQL LIMIT).
Pass a positive value for forward pagination. Negative values signal backward pagination to callers; the dialect renders the absolute value.
Sourcepub fn join(self, clause: JoinClause) -> Self
pub fn join(self, clause: JoinClause) -> Self
Adds a JOIN clause.
Sourcepub fn inner_join(
self,
table: impl Into<String>,
on: Expr,
items: Vec<SelectItem>,
) -> Self
pub fn inner_join( self, table: impl Into<String>, on: Expr, items: Vec<SelectItem>, ) -> Self
Adds an INNER JOIN clause.
Sourcepub fn left_join(
self,
table: impl Into<String>,
on: Expr,
items: Vec<SelectItem>,
) -> Self
pub fn left_join( self, table: impl Into<String>, on: Expr, items: Vec<SelectItem>, ) -> Self
Adds a LEFT JOIN clause.
Sourcepub fn group_by_column(self, column: ColumnMarker) -> Self
pub fn group_by_column(self, column: ColumnMarker) -> Self
Adds a GROUP BY clause.
Sourcepub fn group_by(self, columns: Vec<ColumnMarker>) -> Self
pub fn group_by(self, columns: Vec<ColumnMarker>) -> Self
Adds multiple columns to the GROUP BY clause.
Sourcepub fn order_by_expr(self, expr: Expr, direction: OrderDir) -> Self
pub fn order_by_expr(self, expr: Expr, direction: OrderDir) -> Self
Adds an ORDER BY clause using an arbitrary expression (e.g. an aggregate function).
Sourcepub fn distinct(self, columns: Vec<String>) -> Self
pub fn distinct(self, columns: Vec<String>) -> Self
Sets the columns to deduplicate on (SELECT DISTINCT / DISTINCT ON).
- Postgres: emits
SELECT DISTINCT ON (col, ...)and requires those columns to appear first inORDER BY(callers should prepend them). - SQLite / MySQL: emits plain
SELECT DISTINCT.
Trait Implementations§
Source§impl Clone for SelectBuilder
impl Clone for SelectBuilder
Source§fn clone(&self) -> SelectBuilder
fn clone(&self) -> SelectBuilder
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for SelectBuilder
impl RefUnwindSafe for SelectBuilder
impl Send for SelectBuilder
impl Sync for SelectBuilder
impl Unpin for SelectBuilder
impl UnsafeUnpin for SelectBuilder
impl UnwindSafe for SelectBuilder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more