English | 简体中文

api-docs / org.ktorm.schema / BaseTable / aliased

aliased

open fun aliased(alias: String): BaseTable<E> (source code)

Return a new-created table object with all properties (including the table name and columns and so on) being
copied from this table, but applying a new alias given by the parameter.

Usually, table objects are defined as Kotlin singleton objects or subclasses extending from Table. But limited
to the Kotlin language, although the default implementation of this function can create a copied table object
with a specific alias, it’s return type cannot be the same as the caller’s type but only Table.

So we recommend that if we need to use table aliases, please don’t define tables as Kotlin’s singleton objects,
please use classes instead, and override this aliased function to return the same type as the concrete table
classes.

More details can be found on our website: https://www.ktorm.org/en/joining.html#Self-Joining-amp-Table-Aliases