[jOOQ/jOOQ#16392] Regression in fetchCount execution when argument query
uses plain SQL tables This includes: - [jOOQ/jOOQ#16393] Empty derived column lists generate wrong SQL syntax
This commit is contained in:
parent
69c7a5ac0d
commit
8fd072bd72
@ -88,6 +88,7 @@ import static org.jooq.impl.QueryPartListView.wrap;
|
||||
import static org.jooq.impl.SubqueryCharacteristics.DERIVED_TABLE;
|
||||
import static org.jooq.impl.Tools.EMPTY_NAME;
|
||||
import static org.jooq.impl.Tools.combine;
|
||||
import static org.jooq.impl.Tools.isNotEmpty;
|
||||
import static org.jooq.impl.Tools.map;
|
||||
import static org.jooq.impl.Tools.visitSubquery;
|
||||
import static org.jooq.impl.Tools.BooleanDataKey.DATA_AS_REQUIRED;
|
||||
@ -157,6 +158,10 @@ final class Alias<Q extends QueryPart> extends AbstractQueryPart implements UEmp
|
||||
return wrapped;
|
||||
}
|
||||
|
||||
final boolean hasFieldAliases() {
|
||||
return isNotEmpty(fieldAliases);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean isSimple(Context<?> ctx) {
|
||||
return wrapped instanceof Table && !ctx.declareTables()
|
||||
@ -233,7 +238,7 @@ final class Alias<Q extends QueryPart> extends AbstractQueryPart implements UEmp
|
||||
// [#454] [#1801] Some databases don't allow "derived column names" in
|
||||
// "simple class specifications", or "common table expression references".
|
||||
// Hence, wrap the table reference in a subselect
|
||||
if (fieldAliases != null
|
||||
if (hasFieldAliases()
|
||||
&& (SUPPORT_DERIVED_COLUMN_NAMES_SPECIAL1.contains(dialect))
|
||||
&& (wrapped instanceof TableImpl || wrapped instanceof CommonTableExpressionImpl)) {
|
||||
|
||||
@ -243,7 +248,7 @@ final class Alias<Q extends QueryPart> extends AbstractQueryPart implements UEmp
|
||||
// [#1801] Some databases do not support "derived column names".
|
||||
// They can be emulated by concatenating a dummy SELECT with no
|
||||
// results using UNION ALL
|
||||
else if (fieldAliases != null && (
|
||||
else if (hasFieldAliases() && (
|
||||
emulatedDerivedColumnList
|
||||
|| SUPPORT_DERIVED_COLUMN_NAMES_SPECIAL2.contains(dialect)
|
||||
|
||||
@ -341,7 +346,7 @@ final class Alias<Q extends QueryPart> extends AbstractQueryPart implements UEmp
|
||||
.qualify(false, c -> c.visit(alias));
|
||||
|
||||
// [#1801] Add field aliases to the table alias, if applicable
|
||||
if (fieldAliases != null && !emulatedDerivedColumnList) {
|
||||
if (hasFieldAliases() && !emulatedDerivedColumnList) {
|
||||
toSQLDerivedColumnList(context);
|
||||
}
|
||||
|
||||
|
||||
@ -231,7 +231,7 @@ final class InlineDerivedTable<R extends Record> extends DerivedTable<R> {
|
||||
if (u.where != null) {
|
||||
Select<R> q = new InlineDerivedTable<>(u).query();
|
||||
|
||||
if (a.hasFieldAliases())
|
||||
if (a.alias.hasFieldAliases())
|
||||
return q.asTable(a.getUnqualifiedName(), a.alias.fieldAliases);
|
||||
else
|
||||
return q.asTable(a);
|
||||
|
||||
@ -104,7 +104,7 @@ implements
|
||||
|
||||
// [#13418]
|
||||
List<Field<?>> result = Tools.map(this.alias.wrapped().fieldsRow().fields(), (f, i) -> new TableFieldImpl(
|
||||
hasFieldAliases() && alias.fieldAliases.length > i
|
||||
alias.hasFieldAliases() && alias.fieldAliases.length > i
|
||||
? alias.fieldAliases[i]
|
||||
: f.getUnqualifiedName(), removeGenerator(CONFIG.get(), f.getDataType()), this, f.getCommentPart(), f.getBinding()
|
||||
));
|
||||
@ -112,10 +112,6 @@ implements
|
||||
return new FieldsImpl<>(result);
|
||||
}
|
||||
|
||||
final boolean hasFieldAliases() {
|
||||
return alias.fieldAliases != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the aliased table wrapped by this table.
|
||||
*/
|
||||
|
||||
Loading…
Reference in New Issue
Block a user