pub struct SetOp<D, Output> { /* private fields */ }Expand description
A chain of SELECTs combined by set operators, all decoding to the first
branch’s Output, which is also where SQL itself takes the combined
result’s column names from. ORDER BY here is necessarily by ordinal
position (ORDER BY 1, 1-indexed) rather than a typed column. The
branches can have entirely different Scopes, so once they are combined
there is no single scope left to check a column reference against.
Ordinal position is the only reference SQL itself allows in this position.
Implementations§
Source§impl<D: Dialect, L> SetOp<D, Row<L>>
impl<D: Dialect, L> SetOp<D, Row<L>>
Sourcepub fn order_by_column<K, Idx>(self, _key: K, dir: SortDir) -> Self
pub fn order_by_column<K, Idx>(self, _key: K, dir: SortDir) -> Self
ORDER BY naming the column instead of counting to it: the position
is row::Field’s index, which the row already carries. A column the
combined result doesn’t select is a compile error, which is the whole
reason no ORDER BY <n> is spellable here. Callable multiple times
like Select::order_by, each call appending a key.
Source§impl<D: Dialect, V: SingleColumn> SetOp<D, V>
A set operation whose branches select one un-tupled column: its output
is a bare value, so there is one position and nothing to name.
impl<D: Dialect, V: SingleColumn> SetOp<D, V>
A set operation whose branches select one un-tupled column: its output is a bare value, so there is one position and nothing to name.
Source§impl<D: Dialect, Output> SetOp<D, Output>
impl<D: Dialect, Output> SetOp<D, Output>
Sourcepub fn union<ScopeB, SelB, IdxB>(self, other: &Select<D, ScopeB, SelB>) -> Self
pub fn union<ScopeB, SelB, IdxB>(self, other: &Select<D, ScopeB, SelB>) -> Self
Appends another branch via UNION (duplicates across branches are
removed, same as plain SQL UNION).
Sourcepub fn union_all<ScopeB, SelB, IdxB>(
self,
other: &Select<D, ScopeB, SelB>,
) -> Self
pub fn union_all<ScopeB, SelB, IdxB>( self, other: &Select<D, ScopeB, SelB>, ) -> Self
Appends another branch via UNION ALL (no deduplication, which is
cheaper than UNION when the branches are already known disjoint, or
when duplicates are meaningful).
Sourcepub fn intersect<ScopeB, SelB, IdxB>(
self,
other: &Select<D, ScopeB, SelB>,
) -> Self
pub fn intersect<ScopeB, SelB, IdxB>( self, other: &Select<D, ScopeB, SelB>, ) -> Self
Appends another branch via INTERSECT (rows present in both).
Sourcepub fn except<ScopeB, SelB, IdxB>(self, other: &Select<D, ScopeB, SelB>) -> Self
pub fn except<ScopeB, SelB, IdxB>(self, other: &Select<D, ScopeB, SelB>) -> Self
Appends another branch via EXCEPT (rows in the accumulated result
so far, minus rows in other).
pub fn limit(self, n: impl IntoRowCount) -> Self
pub fn offset(self, n: impl IntoRowCount) -> Self
Sourcepub fn count_sql(&self, _dialect: D) -> (String, Vec<Value>)
pub fn count_sql(&self, _dialect: D) -> (String, Vec<Value>)
How many rows the combination returns, its own ORDER BY/paging
dropped. The branches keep theirs: a UNION of two LIMITed queries
is a different set from a UNION of the whole ones.