diesel/query_dsl/
join_dsl.rs1use query_builder::AsQuery;
2use query_source::joins::OnClauseWrapper;
3use query_source::{JoinTo, QuerySource, Table};
4
5#[doc(hidden)]
6pub trait InternalJoinDsl<Rhs, Kind, On> {
8 type Output: AsQuery;
9
10 fn join(self, rhs: Rhs, kind: Kind, on: On) -> Self::Output;
11}
12
13impl<T, Rhs, Kind, On> InternalJoinDsl<Rhs, Kind, On> for T
14where
15 T: Table + AsQuery,
16 T::Query: InternalJoinDsl<Rhs, Kind, On>,
17{
18 type Output = <T::Query as InternalJoinDsl<Rhs, Kind, On>>::Output;
19
20 fn join(self, rhs: Rhs, kind: Kind, on: On) -> Self::Output {
21 self.as_query().join(rhs, kind, on)
22 }
23}
24
25#[doc(hidden)]
26pub trait JoinWithImplicitOnClause<Rhs, Kind> {
29 type Output: AsQuery;
30
31 fn join_with_implicit_on_clause(self, rhs: Rhs, kind: Kind) -> Self::Output;
32}
33
34impl<Lhs, Rhs, Kind> JoinWithImplicitOnClause<Rhs, Kind> for Lhs
35where
36 Lhs: JoinTo<Rhs>,
37 Lhs: InternalJoinDsl<<Lhs as JoinTo<Rhs>>::FromClause, Kind, <Lhs as JoinTo<Rhs>>::OnClause>,
38{
39 type Output = <Lhs as InternalJoinDsl<Lhs::FromClause, Kind, Lhs::OnClause>>::Output;
40
41 fn join_with_implicit_on_clause(self, rhs: Rhs, kind: Kind) -> Self::Output {
42 let (from, on) = Lhs::join_target(rhs);
43 self.join(from, kind, on)
44 }
45}
46
47pub trait JoinOnDsl: Sized {
75 fn on<On>(self, on: On) -> OnClauseWrapper<Self, On> {
77 OnClauseWrapper::new(self, on)
78 }
79}
80
81impl<T: QuerySource> JoinOnDsl for T {}