Skip to main content

SetOp

Struct SetOp 

Source
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 there is no single scope left to check a column reference against once they’re combined; ordinal position is the only reference SQL itself allows in this position.

Implementations§

Source§

impl<D: Dialect, L> SetOp<D, Row<L>>

Source

pub fn order_by_column<K, Idx>(self, _key: K, dir: SortDir) -> Self
where K: LookupKey, L: Field<K::Key, Idx>, Idx: Position,

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.

Source

pub fn order_by(self, dir: SortDir) -> Self

Source§

impl<D: Dialect, Output> SetOp<D, Output>

Source

pub fn union<ScopeB, SelB, IdxB>(self, other: &Select<D, ScopeB, SelB>) -> Self
where SelB: Selection<ScopeB, IdxB>, SelB::Output: SameShape<Output>,

Appends another branch via UNION (duplicates across branches are removed, same as plain SQL UNION).

Source

pub fn union_all<ScopeB, SelB, IdxB>( self, other: &Select<D, ScopeB, SelB>, ) -> Self
where SelB: Selection<ScopeB, IdxB>, SelB::Output: SameShape<Output>,

Appends another branch via UNION ALL (no deduplication — cheaper than UNION when the branches are already known disjoint, or when duplicates are meaningful).

Source

pub fn intersect<ScopeB, SelB, IdxB>( self, other: &Select<D, ScopeB, SelB>, ) -> Self
where SelB: Selection<ScopeB, IdxB>, SelB::Output: SameShape<Output>,

Appends another branch via INTERSECT (rows present in both).

Source

pub fn except<ScopeB, SelB, IdxB>(self, other: &Select<D, ScopeB, SelB>) -> Self
where SelB: Selection<ScopeB, IdxB>, SelB::Output: SameShape<Output>,

Appends another branch via EXCEPT (rows in the accumulated result so far, minus rows in other).

Source

pub fn limit(self, n: impl IntoRowCount) -> Self

Source

pub fn offset(self, n: impl IntoRowCount) -> Self

Source

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.

Source

pub fn to_sql(&self, _dialect: D) -> (String, Vec<Value>)

Auto Trait Implementations§

§

impl<D, Output> Freeze for SetOp<D, Output>

§

impl<D, Output> RefUnwindSafe for SetOp<D, Output>

§

impl<D, Output> Send for SetOp<D, Output>

§

impl<D, Output> Sync for SetOp<D, Output>

§

impl<D, Output> Unpin for SetOp<D, Output>

§

impl<D, Output> UnsafeUnpin for SetOp<D, Output>

§

impl<D, Output> UnwindSafe for SetOp<D, Output>

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> 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<S> Superset<Nil, Nil> for S

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.
Source§

impl<T> WrapNullable<NotNull> for T