+
Skip to content

Add full outer join #419

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion ktorm-core/src/main/kotlin/org/ktorm/dsl/QuerySource.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@
package org.ktorm.dsl

import org.ktorm.database.Database
import org.ktorm.expression.*
import org.ktorm.expression.BinaryExpression
import org.ktorm.expression.BinaryExpressionType
import org.ktorm.expression.JoinExpression
import org.ktorm.expression.JoinType
import org.ktorm.expression.QuerySourceExpression
import org.ktorm.schema.BaseTable
import org.ktorm.schema.BooleanSqlType
import org.ktorm.schema.ColumnDeclaring
Expand Down Expand Up @@ -102,6 +106,20 @@ public fun QuerySource.rightJoin(right: BaseTable<*>, on: ColumnDeclaring<Boolea
)
}

/**
* Perform a full outer join and return a new [QuerySource], translated to `full outer join` in SQL.
*/
public fun QuerySource.fullOuterJoin(right: BaseTable<*>, on: ColumnDeclaring<Boolean>? = null): QuerySource {
return this.copy(
expression = JoinExpression(
type = JoinType.FULL_OUTER_JOIN,
left = expression,
right = right.asExpression(),
condition = on?.asExpression()
)
)
}

/**
* Return a new-created [Query] object, left joining all the reference tables, and selecting all columns of them.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,12 @@ public enum class JoinType(private val value: String) {
/**
* Right join, translated to the `right join` keyword in SQL.
*/
RIGHT_JOIN("right join");
RIGHT_JOIN("right join"),

/**
* Full outer join, translated to the `full outer join` keyword in SQL.
*/
FULL_OUTER_JOIN("full outer join");

override fun toString(): String {
return value
Expand Down
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载