1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
use crate::dsl;
use crate::query_builder::combination_clause::{
All, CombinationClause, Distinct, Except, Intersect, Union,
};
use crate::query_builder::{AsQuery, Query};
use crate::Table;
pub trait CombineDsl {
type Query: Query;
fn union<Rhs>(self, rhs: Rhs) -> dsl::Union<Self, Rhs>
where
Rhs: AsQuery<SqlType = <Self::Query as Query>::SqlType>;
fn union_all<Rhs>(self, rhs: Rhs) -> dsl::UnionAll<Self, Rhs>
where
Rhs: AsQuery<SqlType = <Self::Query as Query>::SqlType>;
fn intersect<Rhs>(self, rhs: Rhs) -> dsl::Intersect<Self, Rhs>
where
Rhs: AsQuery<SqlType = <Self::Query as Query>::SqlType>;
fn intersect_all<Rhs>(self, rhs: Rhs) -> dsl::IntersectAll<Self, Rhs>
where
Rhs: AsQuery<SqlType = <Self::Query as Query>::SqlType>;
fn except<Rhs>(self, rhs: Rhs) -> dsl::Except<Self, Rhs>
where
Rhs: AsQuery<SqlType = <Self::Query as Query>::SqlType>;
fn except_all<Rhs>(self, rhs: Rhs) -> dsl::ExceptAll<Self, Rhs>
where
Rhs: AsQuery<SqlType = <Self::Query as Query>::SqlType>;
}
impl<T: Table> CombineDsl for T {
type Query = T::Query;
fn union<Rhs>(self, rhs: Rhs) -> dsl::Union<Self, Rhs>
where
Rhs: AsQuery<SqlType = <Self::Query as Query>::SqlType>,
{
CombinationClause::new(Union, Distinct, self.as_query(), rhs.as_query())
}
fn union_all<Rhs>(self, rhs: Rhs) -> dsl::UnionAll<Self, Rhs>
where
Rhs: AsQuery<SqlType = <Self::Query as Query>::SqlType>,
{
CombinationClause::new(Union, All, self.as_query(), rhs.as_query())
}
fn intersect<Rhs>(self, rhs: Rhs) -> dsl::Intersect<Self, Rhs>
where
Rhs: AsQuery<SqlType = <Self::Query as Query>::SqlType>,
{
CombinationClause::new(Intersect, Distinct, self.as_query(), rhs.as_query())
}
fn intersect_all<Rhs>(self, rhs: Rhs) -> dsl::IntersectAll<Self, Rhs>
where
Rhs: AsQuery<SqlType = <Self::Query as Query>::SqlType>,
{
CombinationClause::new(Intersect, All, self.as_query(), rhs.as_query())
}
fn except<Rhs>(self, rhs: Rhs) -> dsl::Except<Self, Rhs>
where
Rhs: AsQuery<SqlType = <Self::Query as Query>::SqlType>,
{
CombinationClause::new(Except, Distinct, self.as_query(), rhs.as_query())
}
fn except_all<Rhs>(self, rhs: Rhs) -> dsl::ExceptAll<Self, Rhs>
where
Rhs: AsQuery<SqlType = <Self::Query as Query>::SqlType>,
{
CombinationClause::new(Except, All, self.as_query(), rhs.as_query())
}
}