MCPcopy Create free account
hub / github.com/sqlalchemy/sqlalchemy / all_

Function all_

lib/sqlalchemy/sql/_elements_constructors.py:63–120  ·  view source on GitHub ↗

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])

Source from the content-addressed store, hash-verified

61
62
63def all_(expr: _ColumnExpressionArgument[_T]) -> CollectionAggregate[bool]:
64 """Produce an ALL expression.
65
66 For dialects such as that of PostgreSQL, this operator applies
67 to usage of the :class:`_types.ARRAY` datatype, for that of
68 MySQL, it may apply to a subquery. e.g.::
69
70 # renders on PostgreSQL:
71 # '5 = ALL (somearray)'
72 expr = 5 == all_(mytable.c.somearray)
73
74 # renders on MySQL:
75 # '5 = ALL (SELECT value FROM table)'
76 expr = 5 == all_(select(table.c.value))
77
78 When using a Python sequence with PostgreSQL, wrap it with
79 :func:`_sql.literal` to produce a SQL expression. Whether the sequence
80 can be adapted to an array parameter is DBAPI-specific::
81
82 expr = 5 == all_(literal([1, 2, 3]))
83
84 Comparison to NULL may work using ``None``::
85
86 None == all_(mytable.c.somearray)
87
88 The any_() / all_() operators also feature a special "operand flipping"
89 behavior such that if any_() / all_() are used on the left side of a
90 comparison using a standalone operator such as ``==``, ``!=``, etc.
91 (not including operator methods such as
92 :meth:`_sql.ColumnOperators.is_`) the rendered expression is flipped::
93
94 # would render '5 = ALL (column)`
95 all_(mytable.c.column) == 5
96
97 Or with ``None``, which note will not perform
98 the usual step of rendering "IS" as is normally the case for NULL::
99
100 # would render 'NULL = ALL(somearray)'
101 all_(mytable.c.somearray) == None
102
103 .. versionchanged:: 1.4.26 repaired the use of any_() / all_()
104 comparing to NULL on the right side to be flipped to the left.
105
106 The column-level :meth:`_sql.ColumnElement.all_` method (not to be
107 confused with :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 return CollectionAggregate._create_all(expr)

Callers 3

test_all_w_comparatorMethod · 0.90

Calls 1

_create_allMethod · 0.80

Tested by 3

test_all_w_comparatorMethod · 0.72