[jOOQ/jOOQ#12210] Aliasing implicit join paths produces invalid queries

This commit is contained in:
Lukas Eder 2021-09-07 13:14:15 +02:00
parent 53dd415c1a
commit 53528b3e86

View File

@ -196,8 +196,19 @@ public class TableImpl<R extends Record> extends AbstractTable<R> implements Sco
super(options, name, schema, comment);
this.fields = new FieldsImpl<>();
this.child = child;
this.childPath = path == null ? null : Tools.aliasedKey((ForeignKey) path, child, this);
if (child != null) {
this.child = child;
this.childPath = path == null ? null : Tools.aliasedKey((ForeignKey) path, child, this);
}
else if (aliased instanceof TableImpl) {
this.child = ((TableImpl<?>) aliased).child;
this.childPath = ((TableImpl) aliased).childPath;
}
else {
this.child = null;
this.childPath = null;
}
if (aliased != null) {
@ -206,12 +217,12 @@ public class TableImpl<R extends Record> extends AbstractTable<R> implements Sco
Alias<Table<R>> existingAlias = Tools.alias(aliased);
if (existingAlias != null)
alias = new Alias<>(existingAlias.wrapped, this, name, existingAlias.fieldAliases, existingAlias.wrapInParentheses);
this.alias = new Alias<>(existingAlias.wrapped, this, name, existingAlias.fieldAliases, existingAlias.wrapInParentheses);
else
alias = new Alias<>(aliased, this, name);
this.alias = new Alias<>(aliased, this, name);
}
else
alias = null;
this.alias = null;
this.parameters = parameters;
}