Skip to content

Commit f6a20e3

Browse files
refactor joinReferences
1 parent e8694f2 commit f6a20e3

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

ktorm-core/src/main/kotlin/org/ktorm/dsl/QuerySource.kt

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -131,13 +131,15 @@ public fun QuerySource.joinReferencesAndSelect(): Query {
131131
.select(joinedTables.flatMap { it.columns })
132132
}
133133

134-
private fun BaseTable<*>.joinReferences(
135-
querySource: QuerySource,
136-
joinedTables: MutableList<BaseTable<*>>
137-
): QuerySource {
138-
139-
var curr = querySource
134+
/**
135+
* Left join all reference tables and return a [QuerySource].
136+
*/
137+
private fun BaseTable<*>.joinReferences(result: QuerySource, joinedTables: MutableList<BaseTable<*>>): QuerySource {
138+
infix fun ColumnDeclaring<*>.eq(column: ColumnDeclaring<*>): BinaryExpression<Boolean> {
139+
return BinaryExpression(BinaryExpressionType.EQUAL, asExpression(), column.asExpression(), BooleanSqlType)
140+
}
140141

142+
var curr = result
141143
joinedTables += this
142144

143145
for (column in columns) {
@@ -156,7 +158,3 @@ private fun BaseTable<*>.joinReferences(
156158

157159
return curr
158160
}
159-
160-
private infix fun ColumnDeclaring<*>.eq(column: ColumnDeclaring<*>): BinaryExpression<Boolean> {
161-
return BinaryExpression(BinaryExpressionType.EQUAL, asExpression(), column.asExpression(), BooleanSqlType)
162-
}

0 commit comments

Comments
 (0)