Allow usage of derived table as aliased parameter of TableImpl constructor

This commit is contained in:
Victor Bronstein 2018-01-30 11:10:05 +02:00
parent 97204d116e
commit 08acef4a9f
2 changed files with 11 additions and 5 deletions

View File

@ -153,8 +153,14 @@ public class TableImpl<R extends Record> extends AbstractTable<R> {
this.fields = new Fields<R>();
if (aliased != null)
alias = new Alias<Table<R>>(aliased, name);
if (aliased != null) {
Alias<Table<R>> existingAlias = Tools.alias(aliased);
if (existingAlias != null) {
alias = existingAlias;
} else {
alias = new Alias<Table<R>>(aliased, name);
}
}
else
alias = null;

View File

@ -4198,11 +4198,11 @@ final class Tools {
return null;
}
static final Alias<? extends Table<?>> alias(Table<?> table) {
static final <R extends Record> Alias<Table<R>> alias(Table<R> table) {
if (table instanceof TableImpl)
return ((TableImpl<?>) table).alias;
return ((TableImpl<R>) table).alias;
else if (table instanceof TableAlias)
return ((TableAlias<?>) table).alias;
return ((TableAlias<R>) table).alias;
else
return null;
}