Merge pull request #7115 from victorbr/typed-derived-table

Allow usage of derived table as aliased parameter of TableImpl constructor
This commit is contained in:
Lukas Eder 2018-02-02 15:55:54 +01:00 committed by GitHub
commit 82a0c85bb9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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

@ -4184,11 +4184,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;
}