Produce an ALL 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 = ALL (somearray)' expr = 5 == all_(myt
(expr: _ColumnExpressionArgument[_T])
| 70 | |
| 71 | |
| 72 | def all_(expr: _ColumnExpressionArgument[_T]) -> CollectionAggregate[bool]: |
| 73 | """Produce an ALL expression. |
| 74 | |
| 75 | For dialects such as that of PostgreSQL, this operator applies |
| 76 | to usage of the :class:`_types.ARRAY` datatype, for that of |
| 77 | MySQL, it may apply to a subquery. e.g.:: |
| 78 | |
| 79 | # renders on PostgreSQL: |
| 80 | # '5 = ALL (somearray)' |
| 81 | expr = 5 == all_(mytable.c.somearray) |
| 82 | |
| 83 | # renders on MySQL: |
| 84 | # '5 = ALL (SELECT value FROM table)' |
| 85 | expr = 5 == all_(select(table.c.value)) |
| 86 | |
| 87 | Comparison to NULL may work using ``None``:: |
| 88 | |
| 89 | None == all_(mytable.c.somearray) |
| 90 | |
| 91 | The any_() / all_() operators also feature a special "operand flipping" |
| 92 | behavior such that if any_() / all_() are used on the left side of a |
| 93 | comparison using a standalone operator such as ``==``, ``!=``, etc. |
| 94 | (not including operator methods such as |
| 95 | :meth:`_sql.ColumnOperators.is_`) the rendered expression is flipped:: |
| 96 | |
| 97 | # would render '5 = ALL (column)` |
| 98 | all_(mytable.c.column) == 5 |
| 99 | |
| 100 | Or with ``None``, which note will not perform |
| 101 | the usual step of rendering "IS" as is normally the case for NULL:: |
| 102 | |
| 103 | # would render 'NULL = ALL(somearray)' |
| 104 | all_(mytable.c.somearray) == None |
| 105 | |
| 106 | The column-level :meth:`_sql.ColumnElement.all_` method (not to be |
| 107 | confused with the deprecated :class:`_types.ARRAY` level |
| 108 | :meth:`_types.ARRAY.Comparator.all`) is shorthand for |
| 109 | ``all_(col)``:: |
| 110 | |
| 111 | 5 == mytable.c.somearray.all_() |
| 112 | |
| 113 | .. seealso:: |
| 114 | |
| 115 | :meth:`_sql.ColumnOperators.all_` |
| 116 | |
| 117 | :func:`_expression.any_` |
| 118 | |
| 119 | """ |
| 120 | if isinstance(expr, operators.ColumnOperators): |
| 121 | return expr.all_() |
| 122 | else: |
| 123 | return CollectionAggregate._create_all(expr) |
| 124 | |
| 125 | |
| 126 | def and_( # type: ignore[empty-body] |
nothing calls this directly
no test coverage detected