[jOOQ/jOOQ#14985] Allow for specifying explicit path joins
- Implement this for INNER JOIN and LEFT JOIN
This commit is contained in:
parent
49b48887c7
commit
cab5e0d78b
@ -227,9 +227,19 @@ class DefaultRenderContext extends AbstractContext<RenderContext> implements Ren
|
||||
Table<?> child = root;
|
||||
List<Table<?>> tables = new ArrayList<>();
|
||||
|
||||
while (root instanceof TableImpl && (child = ((TableImpl<?>) root).child) != null) {
|
||||
tables.add(root);
|
||||
root = child;
|
||||
// [#14985] Traverse paths only when referencing paths (!forceNew),
|
||||
// not when declaring them in FROM (forceNew)
|
||||
if (!forceNew) {
|
||||
while (root instanceof TableImpl && (child = ((TableImpl<?>) root).child) != null) {
|
||||
|
||||
// [#14985] If a subpath has been declared in FROM, join
|
||||
// to that, instead of the root.
|
||||
if (scopeStack.get(root) != null)
|
||||
break;
|
||||
|
||||
tables.add(root);
|
||||
root = child;
|
||||
}
|
||||
}
|
||||
|
||||
e = forceNew
|
||||
|
||||
@ -566,14 +566,20 @@ implements
|
||||
emulateNaturalLeftOuterJoin(ctx) ||
|
||||
emulateNaturalRightOuterJoin(ctx) ||
|
||||
emulateNaturalFullOuterJoin(ctx)) {
|
||||
|
||||
toSQLJoinCondition(ctx, naturalCondition());
|
||||
}
|
||||
|
||||
// Regular JOIN condition
|
||||
else {
|
||||
toSQLJoinCondition(ctx, condition);
|
||||
// [#14985] Path joins additional conditions
|
||||
else if (rhs instanceof TableImpl && ((TableImpl<?>) rhs).child != null) {
|
||||
toSQLJoinCondition(ctx, new Join(((TableImpl<?>) rhs).child, rhs)
|
||||
.onKey(((TableImpl<?>) rhs).childPath)
|
||||
.condition.getWhere().and(condition.getWhere())
|
||||
);
|
||||
}
|
||||
|
||||
// Regular JOIN condition
|
||||
else
|
||||
toSQLJoinCondition(ctx, condition);
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
|
||||
Loading…
Reference in New Issue
Block a user