[jOOQ/jOOQ#16551] [jOOQ/jOOQ#16552] Various improvements
This commit is contained in:
parent
cece52fec3
commit
4172cc91b7
@ -49,6 +49,7 @@ import static org.jooq.SQLDialect.FIREBIRD;
|
||||
import static org.jooq.SQLDialect.H2;
|
||||
import static org.jooq.SQLDialect.MARIADB;
|
||||
// ...
|
||||
// ...
|
||||
import static org.jooq.SQLDialect.MYSQL;
|
||||
// ...
|
||||
// ...
|
||||
|
||||
@ -43,6 +43,7 @@ package org.jooq;
|
||||
// ...
|
||||
import static org.jooq.SQLDialect.DUCKDB;
|
||||
import static org.jooq.SQLDialect.MARIADB;
|
||||
// ...
|
||||
import static org.jooq.SQLDialect.MYSQL;
|
||||
// ...
|
||||
import static org.jooq.SQLDialect.POSTGRES;
|
||||
|
||||
@ -157,6 +157,7 @@ implements
|
||||
|
||||
|
||||
|
||||
|
||||
// https://github.com/ClickHouse/ClickHouse/issues/61020
|
||||
static final Set<SQLDialect> NO_SUPPORT_QUALIFY_IN_WHERE = SQLDialect.supportedBy(CLICKHOUSE);
|
||||
|
||||
@ -296,6 +297,9 @@ implements
|
||||
boolean multiTableJoin = (SUPPORT_MULTITABLE_DELETE.contains(ctx.dialect()) && t instanceof JoinTable);
|
||||
boolean specialDeleteAsSyntax = SPECIAL_DELETE_AS_SYNTAX.contains(ctx.dialect());
|
||||
|
||||
// [#11925] In MySQL, the tables in FROM must be repeated in USING
|
||||
boolean hasUsing = !using.isEmpty() || multiTableJoin || specialDeleteAsSyntax && Tools.alias(t) != null;
|
||||
|
||||
// [#11924] Multiple tables listed in the FROM clause mean this is a
|
||||
// MySQL style multi table DELETE
|
||||
if (multiTableJoin)
|
||||
@ -310,13 +314,14 @@ implements
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// [#2464] Use the USING clause to declare aliases in MySQL
|
||||
else
|
||||
ctx.visit(K_FROM).sql(' ').declareTables(!specialDeleteAsSyntax, c -> c.visit(t));
|
||||
|
||||
// [#11925] In MySQL, the tables in FROM must be repeated in USING
|
||||
boolean hasUsing = !using.isEmpty() || multiTableJoin || specialDeleteAsSyntax && Tools.alias(t) != null;
|
||||
|
||||
// [#14011] Additional predicates that are added for various reasons
|
||||
Condition moreWhere = noCondition();
|
||||
if (hasUsing) {
|
||||
|
||||
@ -47,6 +47,7 @@ import static org.jooq.Clause.INSERT_VALUES;
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
import static org.jooq.SQLDialect.POSTGRES;
|
||||
// ...
|
||||
// ...
|
||||
@ -59,8 +60,10 @@ import static org.jooq.conf.WriteIfReadonly.IGNORE;
|
||||
import static org.jooq.conf.WriteIfReadonly.THROW;
|
||||
import static org.jooq.impl.DSL.name;
|
||||
import static org.jooq.impl.DSL.select;
|
||||
import static org.jooq.impl.DSL.selectFrom;
|
||||
import static org.jooq.impl.Keywords.K_DEFAULT_VALUES;
|
||||
import static org.jooq.impl.Keywords.K_VALUES;
|
||||
import static org.jooq.impl.Names.N_T;
|
||||
import static org.jooq.impl.QueryPartCollectionView.wrap;
|
||||
import static org.jooq.impl.Tools.EMPTY_FIELD;
|
||||
import static org.jooq.impl.Tools.anyMatch;
|
||||
@ -71,6 +74,7 @@ import static org.jooq.impl.Tools.flattenFieldOrRows;
|
||||
import static org.jooq.impl.Tools.lazy;
|
||||
import static org.jooq.impl.Tools.orElse;
|
||||
import static org.jooq.impl.Tools.row0;
|
||||
import static org.jooq.impl.Tools.selectQueryImpl;
|
||||
import static org.jooq.impl.Tools.BooleanDataKey.DATA_STORE_ASSIGNMENT;
|
||||
|
||||
import java.util.AbstractList;
|
||||
@ -88,6 +92,7 @@ import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
import java.util.function.Function;
|
||||
|
||||
import org.jooq.Condition;
|
||||
import org.jooq.Configuration;
|
||||
import org.jooq.Context;
|
||||
import org.jooq.DataType;
|
||||
@ -255,10 +260,27 @@ final class FieldMapsForInsert extends AbstractQueryPart implements UNotYetImple
|
||||
static final void toSQLInsertSelect(Context<?> ctx, Select<?> select) {
|
||||
ctx.formatSeparator()
|
||||
.start(INSERT_SELECT)
|
||||
.visit(select)
|
||||
.visit(patchSelectWithUnions(ctx, select))
|
||||
.end(INSERT_SELECT);
|
||||
}
|
||||
|
||||
private static final Select<?> patchSelectWithUnions(Context<?> ctx, Select<?> select) {
|
||||
switch (ctx.family()) {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
default:
|
||||
return select;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user