diesel::query_dsl

Trait CombineDsl

source
pub trait CombineDsl {
    type Query: Query;

    // Required methods
    fn union<Rhs>(self, rhs: Rhs) -> Union<Self, Rhs>
       where Rhs: AsQuery<SqlType = <Self::Query as Query>::SqlType>;
    fn union_all<Rhs>(self, rhs: Rhs) -> UnionAll<Self, Rhs>
       where Rhs: AsQuery<SqlType = <Self::Query as Query>::SqlType>;
    fn intersect<Rhs>(self, rhs: Rhs) -> Intersect<Self, Rhs>
       where Rhs: AsQuery<SqlType = <Self::Query as Query>::SqlType>;
    fn intersect_all<Rhs>(self, rhs: Rhs) -> IntersectAll<Self, Rhs>
       where Rhs: AsQuery<SqlType = <Self::Query as Query>::SqlType>;
    fn except<Rhs>(self, rhs: Rhs) -> Except<Self, Rhs>
       where Rhs: AsQuery<SqlType = <Self::Query as Query>::SqlType>;
    fn except_all<Rhs>(self, rhs: Rhs) -> ExceptAll<Self, Rhs>
       where Rhs: AsQuery<SqlType = <Self::Query as Query>::SqlType>;
}
Expand description

Extension trait to combine queries using a combinator like UNION, INTERSECT or EXCEPT with or without ALL rule for duplicates

Required Associated Types§

source

type Query: Query

What kind of query does this type represent?

Required Methods§

source

fn union<Rhs>(self, rhs: Rhs) -> Union<Self, Rhs>
where Rhs: AsQuery<SqlType = <Self::Query as Query>::SqlType>,

Combine two queries using a SQL UNION

§Examples
let data = users.select(user_name.nullable())
    .union(animals.select(animal_name).filter(animal_name.is_not_null()))
    .load(connection);

let expected_data = vec![
    Some(String::from("Jack")),
    Some(String::from("Sean")),
    Some(String::from("Tess")),
];
assert_eq!(Ok(expected_data), data);
source

fn union_all<Rhs>(self, rhs: Rhs) -> UnionAll<Self, Rhs>
where Rhs: AsQuery<SqlType = <Self::Query as Query>::SqlType>,

Combine two queries using a SQL UNION ALL

source

fn intersect<Rhs>(self, rhs: Rhs) -> Intersect<Self, Rhs>
where Rhs: AsQuery<SqlType = <Self::Query as Query>::SqlType>,

Combine two queries using a SQL INTERSECT

source

fn intersect_all<Rhs>(self, rhs: Rhs) -> IntersectAll<Self, Rhs>
where Rhs: AsQuery<SqlType = <Self::Query as Query>::SqlType>,

Combine two queries using a SQL INTERSECT ALL

source

fn except<Rhs>(self, rhs: Rhs) -> Except<Self, Rhs>
where Rhs: AsQuery<SqlType = <Self::Query as Query>::SqlType>,

Combine two queries using a SQL EXCEPT

source

fn except_all<Rhs>(self, rhs: Rhs) -> ExceptAll<Self, Rhs>
where Rhs: AsQuery<SqlType = <Self::Query as Query>::SqlType>,

Combine two queries using a SQL EXCEPT ALL

Object Safety§

This trait is not object safe.

Implementors§

source§

impl<'a, ST, QS, DB, GB> CombineDsl for BoxedSelectStatement<'a, ST, QS, DB, GB>
where Self: Query,

source§

type Query = BoxedSelectStatement<'a, ST, QS, DB, GB>

source§

impl<F, S, D, W, O, LOf, G, H, LC> CombineDsl for SelectStatement<F, S, D, W, O, LOf, G, H, LC>
where Self: Query,

source§

type Query = SelectStatement<F, S, D, W, O, LOf, G, H, LC>

source§

impl<S> CombineDsl for Alias<S>
where S: AliasSource, S::Target: Table, Self: AsQuery,

source§

impl<T: Table> CombineDsl for T

source§

type Query = <T as AsQuery>::Query