Vous avez des améliorations (ou des corrections) à proposer pour ce document :
je vous remerçie par avance de m'en faire part, cela m'aide à améliorer le site.
Produce a :class:`_expression.Alias` construct against this
:class:`.FunctionElement`.
.. tip::
The :meth:`_functions.FunctionElement.alias` method is part of the
mechanism by which "table valued" SQL functions are created.
However, most use cases are covered by higher level methods on
:class:`_functions.FunctionElement` including
:meth:`_functions.FunctionElement.table_valued`, and
:meth:`_functions.FunctionElement.column_valued`.
This construct wraps the function in a named alias which
is suitable for the FROM clause, in the style accepted for example
by PostgreSQL. A column expression is also provided using the
special ``.column`` attribute, which may
be used to refer to the output of the function as a scalar value
in the columns or where clause, for a backend such as PostgreSQL.
For a full table-valued expression, use the
:meth:`_functions.FunctionElement.table_valued` method first to
establish named columns.
e.g.:
.. sourcecode:: pycon+sql
>>> from sqlalchemy import func, select, column
>>> data_view = func.unnest([1, 2, 3]).alias("data_view")
>>> print(select(data_view.column))
{printsql}SELECT data_view
FROM unnest(:unnest_1) AS data_view
The :meth:`_functions.FunctionElement.column_valued` method provides
a shortcut for the above pattern:
.. sourcecode:: pycon+sql
>>> data_view = func.unnest([1, 2, 3]).column_valued("data_view")
>>> print(select(data_view))
{printsql}SELECT data_view
FROM unnest(:unnest_1) AS data_view
.. versionadded:: 1.4.0b2 Added the ``.column`` accessor
:param name: alias name, will be rendered as ``AS <name>`` in the
FROM clause
:param joins_implicitly: when True, the table valued function may be
used in the FROM clause without any explicit JOIN to other tables
in the SQL query, and no "cartesian product" warning will be
generated. May be useful for SQL functions such as
``func.json_each()``.
.. versionadded:: 1.4.33
.. seealso::
:ref:`tutorial_functions_table_valued` -
in the :ref:`unified_tutorial`
:meth:`_functions.FunctionElement.table_valued`
:meth:`_functions.FunctionElement.scalar_table_valued`
:meth:`_functions.FunctionElement.column_valued`
Améliorations / Corrections
Vous avez des améliorations (ou des corrections) à proposer pour ce document : je vous remerçie par avance de m'en faire part, cela m'aide à améliorer le site.
Emplacement :
Description des améliorations :