pub struct SelectQuery {Show 14 fields
pub with: With,
pub distinct: bool,
pub select_list: SelectList,
pub values: Values,
pub from: TableRef,
pub extra_from: Vec<TableRef>,
pub where_: Where,
pub group_by: GroupBy,
pub having: Having,
pub windows: Windows,
pub compounds: Compounds,
pub order_by: OrderBy,
pub limit: Limit,
pub offset: Offset,
}Expand description
A SQLite SELECT.
The field order is the clause order of https://www.sqlite.org/lang_select.html:
[ WITH [ RECURSIVE ] common-table-expression [, ...] ]
select-core [ compound-operator select-core ]*
[ ORDER BY ordering-term [, ...] ]
[ LIMIT expr [ ( OFFSET | , ) expr ] ]
select-core:
SELECT [ DISTINCT | ALL ] result-column [, ...]
[ FROM table-or-subquery [, ...] | join-clause ]
[ WHERE expr ]
[ GROUP BY expr [, ...] [ HAVING expr ] ]
[ WINDOW window-name AS window-defn [, ...] ]
| VALUES ( expr [, ...] ) [, ...]Three things in that grammar are unlike PostgreSQL’s, and all three are visible in this type.
A compound operand is a bare select-core. There are no parentheses around
it and none may be added — a parenthesised select is a table-or-subquery in
SQLite, never a compound operand. So the ORDER BY and LIMIT after the last
operand are the only ones there can be, they always apply to the whole
compound, and this type therefore has one set of them rather than PostgreSQL’s
two. See Compound.
OFFSET lives inside the LIMIT production. SELECT … OFFSET 5 with no
LIMIT is a syntax error, so an offset without a limit is a recorded
Error::Incomplete rather than SQL that will be rejected later.
VALUES (…), (…) is a select-core in its own right. values
is that alternative: when it is non-empty the statement is a VALUES
statement, and the clauses that only a SELECT core can carry are a recorded
failure rather than silently dropped. A real SQLite additionally refuses
ORDER BY/LIMIT when the last core is a VALUES, which its own parser
accepts; that one is left to the engine, since whether it holds depends on what
is compounded after the VALUES.
Fields§
§with: WithWITH ….
distinct: boolSELECT DISTINCT. false is ALL, the default, which adds nothing.
select_list: SelectListThe result columns. Empty renders *.
values: ValuesThe VALUES (…), (…) alternative to the whole SELECT core.
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 ….
compounds: CompoundsThe compound operands, applied left to right.
order_by: OrderByORDER BY …, which belongs to the whole compound when there is one.
limit: LimitLIMIT ….
offset: OffsetOFFSET …, which cannot stand without a limit.
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 HasCompounds for SelectQuery
impl HasCompounds for SelectQuery
Source§fn compounds_mut(&mut self) -> &mut Compounds
fn compounds_mut(&mut self) -> &mut Compounds
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 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 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 HasValues for SelectQuery
impl HasValues for SelectQuery
Source§fn values_mut(&mut self) -> &mut Values
fn values_mut(&mut self) -> &mut Values
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.