MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / any

Method any

lib/sqlalchemy/sql/sqltypes.py:3224–3264  ·  view source on GitHub ↗

Return ``other operator ANY (array)`` clause. Usage of array-specific :meth:`_types.ARRAY.Comparator.any` is as follows:: from sqlalchemy.sql import operators conn.execute( select(table.c.data).where(table.c.data.any(7, o

(
            self, other: Any, operator: Optional[OperatorType] = None
        )

Source from the content-addressed store, hash-verified

3222 )
3223 @util.preload_module("sqlalchemy.sql.elements")
3224 def any(
3225 self, other: Any, operator: Optional[OperatorType] = None
3226 ) -> ColumnElement[bool]:
3227 """Return ``other operator ANY (array)`` clause.
3228
3229 Usage of array-specific :meth:`_types.ARRAY.Comparator.any`
3230 is as follows::
3231
3232 from sqlalchemy.sql import operators
3233
3234 conn.execute(
3235 select(table.c.data).where(table.c.data.any(7, operator=operators.lt))
3236 )
3237
3238 :param other: expression to be compared
3239 :param operator: an operator object from the
3240 :mod:`sqlalchemy.sql.operators`
3241 package, defaults to :func:`.operators.eq`.
3242
3243 .. seealso::
3244
3245 :func:`_expression.any_`
3246
3247 :meth:`.types.ARRAY.Comparator.all`
3248
3249 """ # noqa: E501
3250 elements = util.preloaded.sql_elements
3251 operator = operator if operator else operators.eq
3252
3253 arr_type = self.type
3254
3255 return elements.CollectionAggregate._create_any(self.expr).operate(
3256 operators.mirror(operator),
3257 coercions.expect(
3258 roles.BinaryElementRole,
3259 element=other,
3260 operator=operator,
3261 expr=self.expr,
3262 bindparam_type=arr_type.item_type,
3263 ),
3264 )
3265
3266 @util.deprecated(
3267 "2.1",

Callers

nothing calls this directly

Calls 2

_create_anyMethod · 0.80
operateMethod · 0.45

Tested by

no test coverage detected