pub struct SelectQuery {Show 15 fields
pub with: With,
pub distinct: Option<Distinct>,
pub select_list: SelectList,
pub from: TableRef,
pub extra_from: Vec<TableRef>,
pub where_: Where,
pub group_by: GroupBy,
pub having: Having,
pub windows: Windows,
pub order_by: OrderBy,
pub limit: Limit,
pub offset: Offset,
pub fetch: Fetch,
pub locks: Locks,
pub combines: Combines,
}Expand description
A PostgreSQL SELECT.
The field order is the clause order of https://www.postgresql.org/docs/17/sql-select.html:
[ WITH [ RECURSIVE ] with_query [, ...] ]
SELECT [ ALL | DISTINCT [ ON ( expression [, ...] ) ] ]
[ * | expression [ [ AS ] output_name ] [, ...] ]
[ FROM from_item [, ...] ]
[ WHERE condition ]
[ GROUP BY [ ALL | DISTINCT ] grouping_element [, ...] ]
[ HAVING condition ]
[ WINDOW window_name AS ( window_definition ) [, ...] ]
[ { UNION | INTERSECT | EXCEPT } [ ALL | DISTINCT ] select ]
[ ORDER BY expression [ ASC | DESC | USING operator ] [ NULLS { FIRST | LAST } ] [, ...] ]
[ LIMIT { count | ALL } ]
[ OFFSET start [ ROW | ROWS ] ]
[ FETCH { FIRST | NEXT } [ count ] { ROW | ROWS } { ONLY | WITH TIES } ]
[ FOR { UPDATE | NO KEY UPDATE | SHARE | KEY SHARE } [ OF table_name [, ...] ]
[ NOWAIT | SKIP LOCKED ] [...] ]The set-operation line is the one the layout does not mirror, and deliberately: the trailing clauses after it belong to the combination, not to this query, and PostgreSQL says so —
Without parentheses, these clauses will be taken to apply to the result of the
UNION, not to its right-hand input expression.
— so this query’s own ORDER BY/LIMIT/OFFSET/FETCH/FOR render where the
fields sit and the whole thing is parenthesised when something is combined onto
it, while the combination’s live inside Combines.
Fields§
§with: WithWITH ….
distinct: Option<Distinct>DISTINCT / DISTINCT ON (…). None is ALL, the default.
select_list: SelectListThe projection. Empty renders *.
from: TableRefThe first FROM item, with its joins.
extra_from: Vec<TableRef>Further comma-separated FROM items.
where_: WhereWHERE ….
group_by: GroupByGROUP BY ….
having: HavingHAVING ….
windows: WindowsWINDOW ….
order_by: OrderByORDER BY … — this query’s own.
limit: LimitLIMIT … — this query’s own.
offset: OffsetOFFSET … — this query’s own.
fetch: FetchFETCH … — this query’s own.
locks: LocksFOR UPDATE ….
combines: CombinesThe set operations, and the trailing clauses that belong to their result.
Implementations§
Source§impl SelectQuery
impl SelectQuery
Sourcepub fn new() -> SelectQuery
pub fn new() -> SelectQuery
An empty SELECT, which renders SELECT *.
Sourcepub fn apply(&mut self, mods: impl Mod<SelectQuery>)
pub fn apply(&mut self, mods: impl Mod<SelectQuery>)
Apply more mods to an existing query.
Trait Implementations§
Source§impl Clone for SelectQuery
impl Clone for SelectQuery
Source§fn clone(&self) -> SelectQuery
fn clone(&self) -> SelectQuery
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for SelectQuery
impl Debug for SelectQuery
Source§impl Default for SelectQuery
impl Default for SelectQuery
Source§fn default() -> SelectQuery
fn default() -> SelectQuery
Source§impl Expression for SelectQuery
impl Expression for SelectQuery
Source§impl HasCombines for SelectQuery
impl HasCombines for SelectQuery
Source§fn combines_mut(&mut self) -> &mut Combines
fn combines_mut(&mut self) -> &mut Combines
Source§impl HasExtraTables for SelectQuery
impl HasExtraTables for SelectQuery
Source§fn extra_tables_mut(&mut self) -> &mut Vec<TableRef>
fn extra_tables_mut(&mut self) -> &mut Vec<TableRef>
Source§impl HasFetch for SelectQuery
impl HasFetch for SelectQuery
Source§impl HasGroupBy for SelectQuery
impl HasGroupBy for SelectQuery
Source§fn group_by_mut(&mut self) -> &mut GroupBy
fn group_by_mut(&mut self) -> &mut GroupBy
GROUP BY clause to modify.Source§impl HasHaving for SelectQuery
impl HasHaving for SelectQuery
Source§fn having_mut(&mut self) -> &mut Having
fn having_mut(&mut self) -> &mut Having
HAVING clause to modify.Source§impl HasJoins for SelectQuery
impl HasJoins for SelectQuery
Source§impl HasLimit for SelectQuery
impl HasLimit for SelectQuery
Source§impl HasLocks for SelectQuery
impl HasLocks for SelectQuery
Source§impl HasOffset for SelectQuery
impl HasOffset for SelectQuery
Source§fn offset_mut(&mut self) -> &mut Offset
fn offset_mut(&mut self) -> &mut Offset
OFFSET clause to modify.Source§impl HasOrderBy for SelectQuery
impl HasOrderBy for SelectQuery
Source§fn order_by_mut(&mut self) -> &mut OrderBy
fn order_by_mut(&mut self) -> &mut OrderBy
ORDER BY clause to modify.Source§impl HasSelectList for SelectQuery
impl HasSelectList for SelectQuery
Source§fn select_list_mut(&mut self) -> &mut SelectList
fn select_list_mut(&mut self) -> &mut SelectList
Source§impl HasTableRef for SelectQuery
impl HasTableRef for SelectQuery
Source§fn table_ref_mut(&mut self) -> &mut TableRef
fn table_ref_mut(&mut self) -> &mut TableRef
Source§impl HasWhere for SelectQuery
impl HasWhere for SelectQuery
Source§impl HasWindows for SelectQuery
impl HasWindows for SelectQuery
Source§fn windows_mut(&mut self) -> &mut Windows
fn windows_mut(&mut self) -> &mut Windows
WINDOW clause to modify.