@@ -79,60 +79,49 @@ abstract class KotlinBaseBuilder<W : AbstractWhereDSL<W>, B : KotlinBaseBuilder<
79
79
abstract class KotlinBaseJoiningBuilder <T : AbstractQueryExpressionDSL <T , SelectModel >, W : AbstractWhereDSL <W >,
80
80
B : KotlinBaseJoiningBuilder <T , W , B >> : KotlinBaseBuilder <W , B >() {
81
81
82
- fun join (table : SqlTable , joinCriteria : JoinReceiver ): B =
83
- applySelf {
84
- with (joinCriteria(JoinCollector ())) {
85
- this @KotlinBaseJoiningBuilder.getDsl().join(table, onJoinCriterion, andJoinCriteria)
86
- }
82
+ fun join (table : SqlTable , joinCriteria : JoinReceiver ) =
83
+ applyJoin(joinCriteria) {
84
+ getDsl().join(table, it.onJoinCriterion, it.andJoinCriteria)
87
85
}
88
86
89
- fun join (table : SqlTable , alias : String , joinCriteria : JoinReceiver ): B =
90
- applySelf {
91
- with (joinCriteria(JoinCollector ())) {
92
- this @KotlinBaseJoiningBuilder.getDsl().join(table, alias, onJoinCriterion, andJoinCriteria)
93
- }
87
+ fun join (table : SqlTable , alias : String , joinCriteria : JoinReceiver ) =
88
+ applyJoin(joinCriteria) {
89
+ getDsl().join(table, alias, it.onJoinCriterion, it.andJoinCriteria)
94
90
}
95
91
96
- fun fullJoin (table : SqlTable , joinCriteria : JoinReceiver ): B =
97
- applySelf {
98
- with (joinCriteria(JoinCollector ())) {
99
- this @KotlinBaseJoiningBuilder.getDsl().fullJoin(table, onJoinCriterion, andJoinCriteria)
100
- }
92
+ fun fullJoin (table : SqlTable , joinCriteria : JoinReceiver ) =
93
+ applyJoin(joinCriteria) {
94
+ getDsl().fullJoin(table, it.onJoinCriterion, it.andJoinCriteria)
101
95
}
102
96
103
- fun fullJoin (table : SqlTable , alias : String , joinCriteria : JoinReceiver ): B =
104
- applySelf {
105
- with (joinCriteria(JoinCollector ())) {
106
- this @KotlinBaseJoiningBuilder.getDsl().fullJoin(table, alias, onJoinCriterion, andJoinCriteria)
107
- }
97
+ fun fullJoin (table : SqlTable , alias : String , joinCriteria : JoinReceiver ) =
98
+ applyJoin(joinCriteria) {
99
+ getDsl().fullJoin(table, alias, it.onJoinCriterion, it.andJoinCriteria)
108
100
}
109
101
110
- fun leftJoin (table : SqlTable , joinCriteria : JoinReceiver ): B =
111
- applySelf {
112
- with (joinCriteria(JoinCollector ())) {
113
- this @KotlinBaseJoiningBuilder.getDsl().leftJoin(table, onJoinCriterion, andJoinCriteria)
114
- }
102
+ fun leftJoin (table : SqlTable , joinCriteria : JoinReceiver ) =
103
+ applyJoin(joinCriteria) {
104
+ getDsl().leftJoin(table, it.onJoinCriterion, it.andJoinCriteria)
115
105
}
116
106
117
- fun leftJoin (table : SqlTable , alias : String , joinCriteria : JoinReceiver ): B =
118
- applySelf {
119
- with (joinCriteria(JoinCollector ())) {
120
- this @KotlinBaseJoiningBuilder.getDsl().leftJoin(table, alias, onJoinCriterion, andJoinCriteria)
121
- }
107
+ fun leftJoin (table : SqlTable , alias : String , joinCriteria : JoinReceiver ) =
108
+ applyJoin(joinCriteria) {
109
+ getDsl().leftJoin(table, alias, it.onJoinCriterion, it.andJoinCriteria)
122
110
}
123
111
124
- fun rightJoin (table : SqlTable , joinCriteria : JoinReceiver ): B =
125
- applySelf {
126
- with (joinCriteria(JoinCollector ())) {
127
- this @KotlinBaseJoiningBuilder.getDsl().rightJoin(table, onJoinCriterion, andJoinCriteria)
128
- }
112
+ fun rightJoin (table : SqlTable , joinCriteria : JoinReceiver ) =
113
+ applyJoin(joinCriteria) {
114
+ getDsl().rightJoin(table, it.onJoinCriterion, it.andJoinCriteria)
115
+ }
116
+
117
+ fun rightJoin (table : SqlTable , alias : String , joinCriteria : JoinReceiver ) =
118
+ applyJoin(joinCriteria) {
119
+ getDsl().rightJoin(table, alias, it.onJoinCriterion, it.andJoinCriteria)
129
120
}
130
121
131
- fun rightJoin ( table : SqlTable , alias : String , joinCriteria : JoinReceiver ): B =
122
+ private fun applyJoin ( joinCriteria : JoinReceiver , block : ( JoinCollector ) -> Unit ) =
132
123
applySelf {
133
- with (joinCriteria(JoinCollector ())) {
134
- this @KotlinBaseJoiningBuilder.getDsl().rightJoin(table, alias, onJoinCriterion, andJoinCriteria)
135
- }
124
+ joinCriteria(JoinCollector ()).also (block)
136
125
}
137
126
138
127
protected abstract fun getDsl (): AbstractQueryExpressionDSL <T , SelectModel >
0 commit comments