[jOOQ/jOOQ#2682] [jOOQ/jOOQ#15632] Support UPDATE / DELETE .. JOIN
This commit is contained in:
parent
99c44d376b
commit
169493ea8e
@ -82,7 +82,9 @@ import static org.jooq.impl.DSL.noCondition;
|
||||
import static org.jooq.impl.DSL.row;
|
||||
import static org.jooq.impl.DSL.select;
|
||||
import static org.jooq.impl.DSL.trueCondition;
|
||||
import static org.jooq.impl.InlineDerivedTable.hasInlineDerivedTables;
|
||||
import static org.jooq.impl.InlineDerivedTable.transformInlineDerivedTables;
|
||||
import static org.jooq.impl.InlineDerivedTable.transformInlineDerivedTables0;
|
||||
import static org.jooq.impl.Internal.hash;
|
||||
import static org.jooq.impl.Keywords.K_DELETE;
|
||||
import static org.jooq.impl.Keywords.K_FROM;
|
||||
@ -256,24 +258,21 @@ implements
|
||||
// [#2682] [#15632] Apply inline derived tables to the target table
|
||||
// [#15632] TODO: Refactor this logic with UpdateQueryImpl
|
||||
Table<?> t = table(ctx);
|
||||
Table<?> i = InlineDerivedTable.inlineDerivedTable(ctx, t);
|
||||
InlineDerivedTable<?> j = i instanceof InlineDerivedTable ? (InlineDerivedTable<?>) i : null;
|
||||
ConditionProviderImpl where = new ConditionProviderImpl();
|
||||
TableList u = transformInlineDerivedTables(ctx, using, where);
|
||||
if (hasInlineDerivedTables(ctx, t) || hasInlineDerivedTables(ctx, using)) {
|
||||
ConditionProviderImpl where = new ConditionProviderImpl();
|
||||
TableList u = transformInlineDerivedTables(ctx, using, where);
|
||||
|
||||
if (j != null || u != using) {
|
||||
copy(
|
||||
d -> {
|
||||
if (j != null) {
|
||||
d.addConditions(j.condition);
|
||||
}
|
||||
if (u != using) {
|
||||
d.addConditions(where);
|
||||
d.using.clear();
|
||||
d.using.addAll(u);
|
||||
}
|
||||
|
||||
if (where.hasWhere())
|
||||
d.addConditions(where);
|
||||
},
|
||||
(Table<?>) (j != null ? j.table : t)
|
||||
transformInlineDerivedTables0(ctx, t, where, false)
|
||||
).accept0(ctx);
|
||||
}
|
||||
else
|
||||
|
||||
@ -89,7 +89,9 @@ import static org.jooq.impl.DSL.row;
|
||||
import static org.jooq.impl.DSL.select;
|
||||
import static org.jooq.impl.DSL.selectFrom;
|
||||
import static org.jooq.impl.DSL.trueCondition;
|
||||
import static org.jooq.impl.InlineDerivedTable.hasInlineDerivedTables;
|
||||
import static org.jooq.impl.InlineDerivedTable.transformInlineDerivedTables;
|
||||
import static org.jooq.impl.InlineDerivedTable.transformInlineDerivedTables0;
|
||||
import static org.jooq.impl.Keywords.K_FROM;
|
||||
import static org.jooq.impl.Keywords.K_ORDER_BY;
|
||||
import static org.jooq.impl.Keywords.K_SET;
|
||||
@ -566,24 +568,21 @@ implements
|
||||
// [#2682] [#15632] Apply inline derived tables to the target table
|
||||
// [#15632] TODO: Refactor this logic with DeleteQueryImpl
|
||||
Table<?> t = table(ctx);
|
||||
Table<?> i = InlineDerivedTable.inlineDerivedTable(ctx, t);
|
||||
InlineDerivedTable<?> j = i instanceof InlineDerivedTable ? (InlineDerivedTable<?>) i : null;
|
||||
ConditionProviderImpl where = new ConditionProviderImpl();
|
||||
TableList f = transformInlineDerivedTables(ctx, from, where);
|
||||
if (hasInlineDerivedTables(ctx, t) || hasInlineDerivedTables(ctx, from)) {
|
||||
ConditionProviderImpl where = new ConditionProviderImpl();
|
||||
TableList f = transformInlineDerivedTables(ctx, from, where);
|
||||
|
||||
if (j != null || f != from) {
|
||||
copy(
|
||||
d -> {
|
||||
if (j != null) {
|
||||
d.addConditionsForInlineDerivedTable(j.condition);
|
||||
}
|
||||
if (f != from) {
|
||||
d.addConditionsForInlineDerivedTable(where);
|
||||
d.from.clear();
|
||||
d.from.addAll(f);
|
||||
}
|
||||
|
||||
if (where.hasWhere())
|
||||
d.addConditionsForInlineDerivedTable(where);
|
||||
},
|
||||
(Table<?>) (j != null ? j.table : t)
|
||||
transformInlineDerivedTables0(ctx, t, where, false)
|
||||
).accept0(ctx);
|
||||
}
|
||||
else
|
||||
|
||||
Loading…
Reference in New Issue
Block a user