[jOOQ/jOOQ#15936] Implicit path correlation produces correlation
predicate in ON clause rather than WHERE clause in some cases
This commit is contained in:
parent
74d999a5ef
commit
97f2b8be00
@ -7,8 +7,8 @@ plugins {
|
||||
}
|
||||
|
||||
java {
|
||||
sourceCompatibility = JavaVersion.VERSION_17
|
||||
targetCompatibility = JavaVersion.VERSION_17
|
||||
sourceCompatibility = JavaVersion.VERSION_21
|
||||
targetCompatibility = JavaVersion.VERSION_21
|
||||
}
|
||||
|
||||
repositories {
|
||||
|
||||
@ -46,12 +46,12 @@
|
||||
<configuration>
|
||||
<encoding>UTF-8</encoding>
|
||||
|
||||
<release>17</release>
|
||||
<release>21</release>
|
||||
|
||||
|
||||
<!-- IntelliJ needs these https://youtrack.jetbrains.com/issue/IDEA-195472 -->
|
||||
<source>17</source>
|
||||
<target>17</target>
|
||||
<source>21</source>
|
||||
<target>21</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
|
||||
@ -658,8 +658,8 @@ abstract class JoinTable<J extends JoinTable<J>> extends AbstractJoinTable<J> {
|
||||
&& ctx.data(DATA_RENDER_IMPLICIT_JOIN) == null
|
||||
) {
|
||||
toSQLJoinCondition(ctx, DSL.and(
|
||||
lhs instanceof TableImpl<?> ti ? ti.pathCondition() : noCondition(),
|
||||
rhs instanceof TableImpl<?> ti ? ti.pathCondition() : noCondition(),
|
||||
lhs instanceof TableImpl<?> ti ? pathConditionIfInCurrentScope(ctx, ti) : noCondition(),
|
||||
rhs instanceof TableImpl<?> ti ? pathConditionIfInCurrentScope(ctx, ti) : noCondition(),
|
||||
condition.getWhere()
|
||||
));
|
||||
}
|
||||
@ -669,6 +669,14 @@ abstract class JoinTable<J extends JoinTable<J>> extends AbstractJoinTable<J> {
|
||||
toSQLJoinCondition(ctx, condition);
|
||||
}
|
||||
|
||||
private final Condition pathConditionIfInCurrentScope(Context<?> ctx, TableImpl<?> ti) {
|
||||
|
||||
// [#15936] Don't add path correlation predicates to JOIN .. ON clauses.
|
||||
// It's wrong for OUTER JOIN or some nested join trees, and they're already
|
||||
// being added in SelectQueryImpl
|
||||
return ctx.inCurrentScope(ti.path) ? ti.pathCondition() : noCondition();
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
final Condition naturalCondition() {
|
||||
List<Condition> conditions = new ArrayList<>(using.size());
|
||||
|
||||
@ -2983,6 +2983,19 @@ final class SelectQueryImpl<R extends Record> extends AbstractResultQuery<R> imp
|
||||
Table<?> t0 = result.get(i);
|
||||
Table<?> t1 = prependPathJoins(ctx, where, t0, CROSS_JOIN);
|
||||
|
||||
// [#15936] If join tree leaves contain paths, generate the path correlation predicate here
|
||||
// [#15967] But only if they're in scope, and not in the current scope
|
||||
traverseJoins(t1, where, null, l -> true, r -> true, null,
|
||||
(w, t) -> {
|
||||
if (TableImpl.path(t) != null && t instanceof TableImpl<?> ti) {
|
||||
if (ctx.inScope(ti.path) && !ctx.inCurrentScope(ti.path))
|
||||
w.addConditions(ti.pathCondition());
|
||||
}
|
||||
|
||||
return w;
|
||||
}
|
||||
);
|
||||
|
||||
if (t0 != t1)
|
||||
result.set(i, t1);
|
||||
}
|
||||
|
||||
11
pom.xml
11
pom.xml
@ -44,6 +44,9 @@
|
||||
<jaxb.version>4.0.1</jaxb.version>
|
||||
<jaxb.impl.version>4.0.4</jaxb.impl.version>
|
||||
|
||||
<!-- Java version -->
|
||||
<java.version>21</java.version>
|
||||
|
||||
<!-- Scala versions -->
|
||||
<scala.version>2.13.11</scala.version>
|
||||
<scala3.version>3.3.1</scala3.version>
|
||||
@ -587,7 +590,7 @@
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.11.0</version>
|
||||
<version>3.13.0</version>
|
||||
|
||||
<configuration>
|
||||
<!-- When compilers say false, they mean true ...
|
||||
@ -598,12 +601,12 @@
|
||||
<meminitial>256m</meminitial>
|
||||
<encoding>UTF-8</encoding>
|
||||
|
||||
<release>17</release>
|
||||
<release>21</release>
|
||||
|
||||
|
||||
<!-- IntelliJ needs these https://youtrack.jetbrains.com/issue/IDEA-195472 -->
|
||||
<source>17</source>
|
||||
<target>17</target>
|
||||
<source>21</source>
|
||||
<target>21</target>
|
||||
|
||||
<debug>true</debug>
|
||||
<debuglevel>lines,vars,source</debuglevel>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user