[jOOQ/jOOQ#8012] Get Table.where() to work with derived column lists
This commit is contained in:
parent
bcff3882f2
commit
2e8c8d5493
@ -66,7 +66,14 @@ final class InlineDerivedTable<R extends Record> extends DerivedTable<R> {
|
||||
|
||||
@Override
|
||||
final FieldsImpl<R> fields0() {
|
||||
return new FieldsImpl<>(table.as(table).fields());
|
||||
|
||||
// [#8012] Re-use the existing fields row if this is an aliased table
|
||||
if (table instanceof TableAlias)
|
||||
return new FieldsImpl<>(table.fields());
|
||||
|
||||
// [#8012] Re-wrap fields in new TableAlias to prevent StackOverflowError
|
||||
else
|
||||
return new FieldsImpl<>(table.as(table).fields());
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -2727,6 +2727,18 @@ final class SelectQueryImpl<R extends Record> extends AbstractResultQuery<R> imp
|
||||
return new InlineDerivedTable<>(removeWhere(u), u.where).query().asTable(i);
|
||||
}
|
||||
}
|
||||
else if (t instanceof TableAlias<R> a) {
|
||||
if (a.$aliased() instanceof TableImpl<R> u) {
|
||||
if (u.where != null) {
|
||||
Select<R> q = new InlineDerivedTable<>(removeWhere(u), u.where).query();
|
||||
|
||||
if (a.hasFieldAliases())
|
||||
return q.asTable(a.getUnqualifiedName(), a.alias.fieldAliases);
|
||||
else
|
||||
return q.asTable(a);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -104,7 +104,7 @@ implements
|
||||
|
||||
// [#13418]
|
||||
List<Field<?>> result = Tools.map(this.alias.wrapped().fieldsRow().fields(), (f, i) -> new TableFieldImpl(
|
||||
alias.fieldAliases != null && alias.fieldAliases.length > i
|
||||
hasFieldAliases() && alias.fieldAliases.length > i
|
||||
? alias.fieldAliases[i]
|
||||
: f.getUnqualifiedName(), removeGenerator(CONFIG.get(), f.getDataType()), this, f.getCommentPart(), f.getBinding()
|
||||
));
|
||||
@ -112,10 +112,14 @@ implements
|
||||
return new FieldsImpl<>(result);
|
||||
}
|
||||
|
||||
final boolean hasFieldAliases() {
|
||||
return alias.fieldAliases != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the aliased table wrapped by this table.
|
||||
*/
|
||||
Table<R> getAliasedTable() {
|
||||
final Table<R> getAliasedTable() {
|
||||
if (alias != null)
|
||||
return alias.wrapped();
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user