[#7494] Regression on DB2's INSERT .. RETURNING emulation
This commit is contained in:
parent
efa970c49a
commit
84977b97fa
@ -64,9 +64,9 @@ import static org.jooq.impl.Keywords.K_SELECT;
|
||||
import static org.jooq.impl.Keywords.K_SQL;
|
||||
import static org.jooq.impl.Keywords.K_TABLE;
|
||||
import static org.jooq.impl.Tools.EMPTY_FIELD;
|
||||
import static org.jooq.impl.Tools.EMPTY_SELECT_FIELD_OR_ASTERISK;
|
||||
import static org.jooq.impl.Tools.EMPTY_STRING;
|
||||
import static org.jooq.impl.Tools.DataKey.DATA_EMULATE_BULK_INSERT_RETURNING;
|
||||
import static org.jooq.impl.Tools.DataKey.DATA_RENDERING_DB2_FINAL_TABLE_CLAUSE;
|
||||
import static org.jooq.util.sqlite.SQLiteDSL.rowid;
|
||||
|
||||
import java.sql.CallableStatement;
|
||||
@ -104,7 +104,6 @@ import org.jooq.Table;
|
||||
import org.jooq.conf.ExecuteWithoutWhere;
|
||||
import org.jooq.conf.RenderNameStyle;
|
||||
import org.jooq.exception.DataAccessException;
|
||||
import org.jooq.impl.Tools.DataKey;
|
||||
import org.jooq.tools.JooqLogger;
|
||||
import org.jooq.tools.jdbc.JDBCUtils;
|
||||
|
||||
@ -390,8 +389,6 @@ abstract class AbstractDMLQuery<R extends Record> extends AbstractQuery {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -132,6 +132,7 @@ import static org.jooq.impl.Tools.DataKey.DATA_NESTED_SET_OPERATIONS;
|
||||
import static org.jooq.impl.Tools.DataKey.DATA_OMIT_INTO_CLAUSE;
|
||||
import static org.jooq.impl.Tools.DataKey.DATA_OVERRIDE_ALIASES_IN_ORDER_BY;
|
||||
import static org.jooq.impl.Tools.DataKey.DATA_PREFER_TOP_OVER_FETCH;
|
||||
import static org.jooq.impl.Tools.DataKey.DATA_RENDERING_DB2_FINAL_TABLE_CLAUSE;
|
||||
import static org.jooq.impl.Tools.DataKey.DATA_RENDER_TRAILING_LIMIT_IF_APPLICABLE;
|
||||
import static org.jooq.impl.Tools.DataKey.DATA_ROW_VALUE_EXPRESSION_PREDICATE_SUBQUERY;
|
||||
import static org.jooq.impl.Tools.DataKey.DATA_SELECT_INTO_TABLE;
|
||||
@ -1026,6 +1027,7 @@ final class SelectQueryImpl<R extends Record> extends AbstractResultQuery<R> imp
|
||||
private final void toSQLReference0(Context<?> context, Field<?>[] originalFields, Field<?>[] alternativeFields) {
|
||||
SQLDialect dialect = context.dialect();
|
||||
SQLDialect family = dialect.family();
|
||||
boolean qualify = context.qualify();
|
||||
|
||||
int unionOpSize = unionOp.size();
|
||||
boolean unionOpNesting = false;
|
||||
@ -1150,6 +1152,9 @@ final class SelectQueryImpl<R extends Record> extends AbstractResultQuery<R> imp
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
context.declareFields(true);
|
||||
|
||||
// [#2335] When emulating LIMIT .. OFFSET, the SELECT clause needs to generate
|
||||
@ -1184,6 +1189,10 @@ final class SelectQueryImpl<R extends Record> extends AbstractResultQuery<R> imp
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
context.declareFields(false)
|
||||
.end(SELECT_SELECT);
|
||||
|
||||
@ -1437,8 +1446,6 @@ final class SelectQueryImpl<R extends Record> extends AbstractResultQuery<R> imp
|
||||
.sql(") t");
|
||||
|
||||
if (applySeekOnDerivedTable) {
|
||||
boolean qualify = context.qualify();
|
||||
|
||||
context.formatSeparator()
|
||||
.visit(K_WHERE)
|
||||
.sql(' ')
|
||||
@ -1450,7 +1457,6 @@ final class SelectQueryImpl<R extends Record> extends AbstractResultQuery<R> imp
|
||||
|
||||
// ORDER BY clause for UNION
|
||||
// -------------------------
|
||||
boolean qualify = context.qualify();
|
||||
try {
|
||||
context.qualify(false);
|
||||
toSQLOrderBy(
|
||||
|
||||
@ -187,7 +187,6 @@ import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
|
||||
// ...
|
||||
import org.jooq.Asterisk;
|
||||
import org.jooq.Attachable;
|
||||
import org.jooq.BindContext;
|
||||
import org.jooq.Catalog;
|
||||
@ -206,7 +205,6 @@ import org.jooq.Field;
|
||||
import org.jooq.Name;
|
||||
import org.jooq.OrderField;
|
||||
import org.jooq.Param;
|
||||
import org.jooq.QualifiedAsterisk;
|
||||
import org.jooq.Query;
|
||||
import org.jooq.QueryPart;
|
||||
import org.jooq.Record;
|
||||
@ -222,7 +220,6 @@ import org.jooq.RowN;
|
||||
import org.jooq.SQLDialect;
|
||||
import org.jooq.Schema;
|
||||
import org.jooq.Select;
|
||||
import org.jooq.SelectField;
|
||||
import org.jooq.SelectFieldOrAsterisk;
|
||||
import org.jooq.SortField;
|
||||
import org.jooq.Table;
|
||||
@ -4404,32 +4401,6 @@ final class Tools {
|
||||
return false;
|
||||
}
|
||||
|
||||
static final SelectFieldOrAsterisk[] qualify(Table<?> table, SelectFieldOrAsterisk... fields) {
|
||||
if (fields == null)
|
||||
return null;
|
||||
|
||||
SelectFieldOrAsterisk[] result = new SelectFieldOrAsterisk[fields.length];
|
||||
Name[] part = table.getQualifiedName().parts();
|
||||
|
||||
for (int i = 0; i < fields.length; i++) {
|
||||
if (fields[i] instanceof SelectField) {
|
||||
SelectField<?> field = (SelectField<?>) fields[i];
|
||||
Name[] name = new Name[part.length + 1];
|
||||
System.arraycopy(part, 0, name, 0, part.length);
|
||||
name[part.length] = field.getUnqualifiedName();
|
||||
result[i] = DSL.field(DSL.name(name), field.getDataType());
|
||||
}
|
||||
else if (fields[i] instanceof QualifiedAsterisk)
|
||||
result[i] = table.asterisk();
|
||||
else if (fields[i] instanceof Asterisk)
|
||||
result[i] = fields[i];
|
||||
else
|
||||
throw new AssertionError("Type not supported: " + fields[i]);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static final <T> Field<T> qualify(Table<?> table, Field<T> field) {
|
||||
Field<T> result = table.field(field);
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user