Return a named alias of the given :class:`.FromClause`. For :class:`.Table` and :class:`.Join` objects, the return type is the :class:`_expression.Alias` object. Other kinds of :class:`.NamedFromClause` objects may be returned for other kinds of :class:`.FromClause` objects. The na
(
selectable: FromClause[_KeyColCC_co],
name: Optional[str] = None,
flat: bool = False,
)
| 61 | |
| 62 | |
| 63 | def alias( |
| 64 | selectable: FromClause[_KeyColCC_co], |
| 65 | name: Optional[str] = None, |
| 66 | flat: bool = False, |
| 67 | ) -> NamedFromClause[_KeyColCC_co]: |
| 68 | """Return a named alias of the given :class:`.FromClause`. |
| 69 | |
| 70 | For :class:`.Table` and :class:`.Join` objects, the return type is the |
| 71 | :class:`_expression.Alias` object. Other kinds of :class:`.NamedFromClause` |
| 72 | objects may be returned for other kinds of :class:`.FromClause` objects. |
| 73 | |
| 74 | The named alias represents any :class:`_expression.FromClause` with an |
| 75 | alternate name assigned within SQL, typically using the ``AS`` clause when |
| 76 | generated, e.g. ``SELECT * FROM table AS aliasname``. |
| 77 | |
| 78 | Equivalent functionality is available via the |
| 79 | :meth:`_expression.FromClause.alias` |
| 80 | method available on all :class:`_expression.FromClause` objects. |
| 81 | |
| 82 | :param selectable: any :class:`_expression.FromClause` subclass, |
| 83 | such as a table, select statement, etc. |
| 84 | |
| 85 | :param name: string name to be assigned as the alias. |
| 86 | If ``None``, a name will be deterministically generated at compile |
| 87 | time. Deterministic means the name is guaranteed to be unique against |
| 88 | other constructs used in the same statement, and will also be the same |
| 89 | name for each successive compilation of the same statement object. |
| 90 | |
| 91 | :param flat: Will be passed through to if the given selectable |
| 92 | is an instance of :class:`_expression.Join` - see |
| 93 | :meth:`_expression.Join.alias` for details. |
| 94 | |
| 95 | """ |
| 96 | return Alias._factory(selectable, name=name, flat=flat) |
| 97 | |
| 98 | |
| 99 | def cte( |