Skip to content

Commit

Permalink
Review issues: remove lateral parameter from leftJoin, crossJoin, and…
Browse files Browse the repository at this point in the history
… so on.
  • Loading branch information
obabichevjb committed Jun 7, 2024
1 parent d6f31f4 commit d5d0245
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 24 deletions.
20 changes: 10 additions & 10 deletions exposed-core/api/exposed-core.api
Original file line number Diff line number Diff line change
Expand Up @@ -2449,16 +2449,16 @@ public final class org/jetbrains/exposed/sql/Table$PrimaryKey {
}

public final class org/jetbrains/exposed/sql/TableKt {
public static final fun crossJoin (Lorg/jetbrains/exposed/sql/ColumnSet;Lorg/jetbrains/exposed/sql/ColumnSet;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;ZLkotlin/jvm/functions/Function1;)Lorg/jetbrains/exposed/sql/Join;
public static synthetic fun crossJoin$default (Lorg/jetbrains/exposed/sql/ColumnSet;Lorg/jetbrains/exposed/sql/ColumnSet;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;ZLkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lorg/jetbrains/exposed/sql/Join;
public static final fun fullJoin (Lorg/jetbrains/exposed/sql/ColumnSet;Lorg/jetbrains/exposed/sql/ColumnSet;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;ZLkotlin/jvm/functions/Function1;)Lorg/jetbrains/exposed/sql/Join;
public static synthetic fun fullJoin$default (Lorg/jetbrains/exposed/sql/ColumnSet;Lorg/jetbrains/exposed/sql/ColumnSet;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;ZLkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lorg/jetbrains/exposed/sql/Join;
public static final fun innerJoin (Lorg/jetbrains/exposed/sql/ColumnSet;Lorg/jetbrains/exposed/sql/ColumnSet;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;ZLkotlin/jvm/functions/Function1;)Lorg/jetbrains/exposed/sql/Join;
public static synthetic fun innerJoin$default (Lorg/jetbrains/exposed/sql/ColumnSet;Lorg/jetbrains/exposed/sql/ColumnSet;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;ZLkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lorg/jetbrains/exposed/sql/Join;
public static final fun leftJoin (Lorg/jetbrains/exposed/sql/ColumnSet;Lorg/jetbrains/exposed/sql/ColumnSet;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;ZLkotlin/jvm/functions/Function1;)Lorg/jetbrains/exposed/sql/Join;
public static synthetic fun leftJoin$default (Lorg/jetbrains/exposed/sql/ColumnSet;Lorg/jetbrains/exposed/sql/ColumnSet;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;ZLkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lorg/jetbrains/exposed/sql/Join;
public static final fun rightJoin (Lorg/jetbrains/exposed/sql/ColumnSet;Lorg/jetbrains/exposed/sql/ColumnSet;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;ZLkotlin/jvm/functions/Function1;)Lorg/jetbrains/exposed/sql/Join;
public static synthetic fun rightJoin$default (Lorg/jetbrains/exposed/sql/ColumnSet;Lorg/jetbrains/exposed/sql/ColumnSet;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;ZLkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lorg/jetbrains/exposed/sql/Join;
public static final fun crossJoin (Lorg/jetbrains/exposed/sql/ColumnSet;Lorg/jetbrains/exposed/sql/ColumnSet;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;)Lorg/jetbrains/exposed/sql/Join;
public static synthetic fun crossJoin$default (Lorg/jetbrains/exposed/sql/ColumnSet;Lorg/jetbrains/exposed/sql/ColumnSet;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lorg/jetbrains/exposed/sql/Join;
public static final fun fullJoin (Lorg/jetbrains/exposed/sql/ColumnSet;Lorg/jetbrains/exposed/sql/ColumnSet;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;)Lorg/jetbrains/exposed/sql/Join;
public static synthetic fun fullJoin$default (Lorg/jetbrains/exposed/sql/ColumnSet;Lorg/jetbrains/exposed/sql/ColumnSet;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lorg/jetbrains/exposed/sql/Join;
public static final fun innerJoin (Lorg/jetbrains/exposed/sql/ColumnSet;Lorg/jetbrains/exposed/sql/ColumnSet;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;)Lorg/jetbrains/exposed/sql/Join;
public static synthetic fun innerJoin$default (Lorg/jetbrains/exposed/sql/ColumnSet;Lorg/jetbrains/exposed/sql/ColumnSet;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lorg/jetbrains/exposed/sql/Join;
public static final fun leftJoin (Lorg/jetbrains/exposed/sql/ColumnSet;Lorg/jetbrains/exposed/sql/ColumnSet;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;)Lorg/jetbrains/exposed/sql/Join;
public static synthetic fun leftJoin$default (Lorg/jetbrains/exposed/sql/ColumnSet;Lorg/jetbrains/exposed/sql/ColumnSet;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lorg/jetbrains/exposed/sql/Join;
public static final fun rightJoin (Lorg/jetbrains/exposed/sql/ColumnSet;Lorg/jetbrains/exposed/sql/ColumnSet;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;)Lorg/jetbrains/exposed/sql/Join;
public static synthetic fun rightJoin$default (Lorg/jetbrains/exposed/sql/ColumnSet;Lorg/jetbrains/exposed/sql/ColumnSet;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lorg/jetbrains/exposed/sql/Join;
public static final fun targetTables (Lorg/jetbrains/exposed/sql/ColumnSet;)Ljava/util/List;
}

Expand Down
15 changes: 5 additions & 10 deletions exposed-core/src/main/kotlin/org/jetbrains/exposed/sql/Table.kt
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,8 @@ fun <C1 : ColumnSet, C2 : ColumnSet> C1.innerJoin(
otherTable: C2,
onColumn: (C1.() -> Expression<*>)? = null,
otherColumn: (C2.() -> Expression<*>)? = null,
lateral: Boolean = false,
additionalConstraint: (SqlExpressionBuilder.() -> Op<Boolean>)? = null,
): Join = join(otherTable, JoinType.INNER, onColumn?.invoke(this), otherColumn?.invoke(otherTable), lateral, additionalConstraint)
): Join = join(otherTable, JoinType.INNER, onColumn?.invoke(this), otherColumn?.invoke(otherTable), false, additionalConstraint)

/**
* Creates a left outer join relation with [otherTable] using [onColumn] and [otherColumn] equality
Expand All @@ -163,9 +162,8 @@ fun <C1 : ColumnSet, C2 : ColumnSet> C1.leftJoin(
otherTable: C2,
onColumn: (C1.() -> Expression<*>)? = null,
otherColumn: (C2.() -> Expression<*>)? = null,
lateral: Boolean = false,
additionalConstraint: (SqlExpressionBuilder.() -> Op<Boolean>)? = null,
): Join = join(otherTable, JoinType.LEFT, onColumn?.invoke(this), otherColumn?.invoke(otherTable), lateral, additionalConstraint)
): Join = join(otherTable, JoinType.LEFT, onColumn?.invoke(this), otherColumn?.invoke(otherTable), false, additionalConstraint)

/**
* Creates a right outer join relation with [otherTable] using [onColumn] and [otherColumn] equality
Expand All @@ -177,9 +175,8 @@ fun <C1 : ColumnSet, C2 : ColumnSet> C1.rightJoin(
otherTable: C2,
onColumn: (C1.() -> Expression<*>)? = null,
otherColumn: (C2.() -> Expression<*>)? = null,
lateral: Boolean = false,
additionalConstraint: (SqlExpressionBuilder.() -> Op<Boolean>)? = null,
): Join = join(otherTable, JoinType.RIGHT, onColumn?.invoke(this), otherColumn?.invoke(otherTable), lateral, additionalConstraint)
): Join = join(otherTable, JoinType.RIGHT, onColumn?.invoke(this), otherColumn?.invoke(otherTable), false, additionalConstraint)

/**
* Creates a full outer join relation with [otherTable] using [onColumn] and [otherColumn] equality
Expand All @@ -191,9 +188,8 @@ fun <C1 : ColumnSet, C2 : ColumnSet> C1.fullJoin(
otherTable: C2,
onColumn: (C1.() -> Expression<*>)? = null,
otherColumn: (C2.() -> Expression<*>)? = null,
lateral: Boolean = false,
additionalConstraint: (SqlExpressionBuilder.() -> Op<Boolean>)? = null,
): Join = join(otherTable, JoinType.FULL, onColumn?.invoke(this), otherColumn?.invoke(otherTable), lateral, additionalConstraint)
): Join = join(otherTable, JoinType.FULL, onColumn?.invoke(this), otherColumn?.invoke(otherTable), false, additionalConstraint)

/**
* Creates a cross join relation with [otherTable] using [onColumn] and [otherColumn] equality
Expand All @@ -205,9 +201,8 @@ fun <C1 : ColumnSet, C2 : ColumnSet> C1.crossJoin(
otherTable: C2,
onColumn: (C1.() -> Expression<*>)? = null,
otherColumn: (C2.() -> Expression<*>)? = null,
lateral: Boolean = false,
additionalConstraint: (SqlExpressionBuilder.() -> Op<Boolean>)? = null,
): Join = join(otherTable, JoinType.CROSS, onColumn?.invoke(this), otherColumn?.invoke(otherTable), lateral, additionalConstraint)
): Join = join(otherTable, JoinType.CROSS, onColumn?.invoke(this), otherColumn?.invoke(otherTable), false, additionalConstraint)

/**
* Represents a subset of [fields] from a given [source].
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@ class LateralJoinTests : DatabaseTestsBase() {
// Cross join
child.selectAll().where { child.value greater parent.value }.limit(1).alias("subquery")
.let { subqueryAlias ->
val query = parent.crossJoin(subqueryAlias, lateral = true)
val query = parent.join(subqueryAlias, JoinType.CROSS, onColumn = parent.id, otherColumn = subqueryAlias[child.parent], lateral = true)

assertEqualLists(listOf(30), query.selectAll().map { it[subqueryAlias[child.value]] })
}

// Left join
child.selectAll().where { child.value greater parent.value }.alias("subquery")
.let { subqueryAlias ->
val query = parent.leftJoin(subqueryAlias, lateral = true, onColumn = { parent.id }, otherColumn = { subqueryAlias[child.parent] })
val query = parent.join(subqueryAlias, JoinType.LEFT, onColumn = parent.id, otherColumn = subqueryAlias[child.parent], lateral = true)

assertEqualLists(listOf(30), query.selectAll().map { it[subqueryAlias[child.value]] })
}
Expand All @@ -52,7 +52,7 @@ class LateralJoinTests : DatabaseTestsBase() {
child.selectAll().where { child.value greater parentQuery[parent.value] }.alias("subquery")
.let { subqueryAlias ->
val query = parentQuery
.leftJoin(subqueryAlias, lateral = true, onColumn = { parentQuery[parent.id] }, otherColumn = { subqueryAlias[child.parent] })
.join(subqueryAlias, JoinType.LEFT, onColumn = parentQuery[parent.id], otherColumn = subqueryAlias[child.parent], lateral = true)

assertEqualLists(listOf(30), query.selectAll().map { it[subqueryAlias[child.value]] })
}
Expand All @@ -63,7 +63,7 @@ class LateralJoinTests : DatabaseTestsBase() {
fun testLateralDirectTableJoin() {
withTestTables { parent, child, testDb ->
expectException<IllegalArgumentException> {
parent.leftJoin(child, lateral = true).selectAll().toList()
parent.join(child, JoinType.LEFT, lateral = true).selectAll().toList()
}
}
}
Expand Down

0 comments on commit d5d0245

Please sign in to comment.