Participer au site avec un Tip
Rechercher
 

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 :

Vous êtes un professionnel et vous avez besoin d'une formation ? Programmation Python
Les fondamentaux
Voir le programme détaillé
Module « sqlalchemy »

Fonction any_ - module sqlalchemy

Signature de la fonction any_

def any_(expr: '_ColumnExpressionArgument[_T]') -> 'CollectionAggregate[bool]' 

Description

help(sqlalchemy.any_)

Produce an ANY expression.

For dialects such as that of PostgreSQL, this operator applies
to usage of the :class:`_types.ARRAY` datatype, for that of
MySQL, it may apply to a subquery.  e.g.::

    # renders on PostgreSQL:
    # '5 = ANY (somearray)'
    expr = 5 == any_(mytable.c.somearray)

    # renders on MySQL:
    # '5 = ANY (SELECT value FROM table)'
    expr = 5 == any_(select(table.c.value))

Comparison to NULL may work using ``None`` or :func:`_sql.null`::

    None == any_(mytable.c.somearray)

The any_() / all_() operators also feature a special "operand flipping"
behavior such that if any_() / all_() are used on the left side of a
comparison using a standalone operator such as ``==``, ``!=``, etc.
(not including operator methods such as
:meth:`_sql.ColumnOperators.is_`) the rendered expression is flipped::

    # would render '5 = ANY (column)`
    any_(mytable.c.column) == 5

Or with ``None``, which note will not perform
the usual step of rendering "IS" as is normally the case for NULL::

    # would render 'NULL = ANY(somearray)'
    any_(mytable.c.somearray) == None

.. versionchanged:: 1.4.26  repaired the use of any_() / all_()
   comparing to NULL on the right side to be flipped to the left.

The column-level :meth:`_sql.ColumnElement.any_` method (not to be
confused with :class:`_types.ARRAY` level
:meth:`_types.ARRAY.Comparator.any`) is shorthand for
``any_(col)``::

    5 = mytable.c.somearray.any_()

.. seealso::

    :meth:`_sql.ColumnOperators.any_`

    :func:`_expression.all_`



Vous êtes un professionnel et vous avez besoin d'une formation ? Programmation Python
Les compléments
Voir le programme détaillé