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
use query_builder::AsQuery;
use query_source::joins::OnClauseWrapper;
use query_source::{JoinTo, QuerySource, Table};
#[doc(hidden)]
pub trait InternalJoinDsl<Rhs, Kind, On> {
type Output: AsQuery;
fn join(self, rhs: Rhs, kind: Kind, on: On) -> Self::Output;
}
impl<T, Rhs, Kind, On> InternalJoinDsl<Rhs, Kind, On> for T
where
T: Table + AsQuery,
T::Query: InternalJoinDsl<Rhs, Kind, On>,
{
type Output = <T::Query as InternalJoinDsl<Rhs, Kind, On>>::Output;
fn join(self, rhs: Rhs, kind: Kind, on: On) -> Self::Output {
self.as_query().join(rhs, kind, on)
}
}
#[doc(hidden)]
pub trait JoinWithImplicitOnClause<Rhs, Kind> {
type Output: AsQuery;
fn join_with_implicit_on_clause(self, rhs: Rhs, kind: Kind) -> Self::Output;
}
impl<Lhs, Rhs, Kind> JoinWithImplicitOnClause<Rhs, Kind> for Lhs
where
Lhs: JoinTo<Rhs>,
Lhs: InternalJoinDsl<<Lhs as JoinTo<Rhs>>::FromClause, Kind, <Lhs as JoinTo<Rhs>>::OnClause>,
{
type Output = <Lhs as InternalJoinDsl<Lhs::FromClause, Kind, Lhs::OnClause>>::Output;
fn join_with_implicit_on_clause(self, rhs: Rhs, kind: Kind) -> Self::Output {
let (from, on) = Lhs::join_target(rhs);
self.join(from, kind, on)
}
}
pub trait JoinOnDsl: Sized {
fn on<On>(self, on: On) -> OnClauseWrapper<Self, On> {
OnClauseWrapper::new(self, on)
}
}
impl<T: QuerySource> JoinOnDsl for T {}