MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / CollectionAggregate

Class CollectionAggregate

lib/sqlalchemy/sql/elements.py:4039–4137  ·  view source on GitHub ↗

Forms the basis for right-hand collection operator modifiers ANY and ALL. The ANY and ALL keywords are available in different ways on different backends. On PostgreSQL, they only work for an ARRAY type. On MySQL, they only work for subqueries.

Source from the content-addressed store, hash-verified

4037
4038
4039class CollectionAggregate(UnaryExpression[_T]):
4040 """Forms the basis for right-hand collection operator modifiers
4041 ANY and ALL.
4042
4043 The ANY and ALL keywords are available in different ways on different
4044 backends. On PostgreSQL, they only work for an ARRAY type. On
4045 MySQL, they only work for subqueries.
4046
4047 """
4048
4049 inherit_cache = True
4050 _is_collection_aggregate = True
4051
4052 @classmethod
4053 def _create_any(
4054 cls, expr: _ColumnExpressionArgument[_T]
4055 ) -> CollectionAggregate[bool]:
4056 """create CollectionAggregate for the legacy
4057 ARRAY.Comparator.any() method"""
4058 col_expr: ColumnElement[_T] = coercions.expect(
4059 roles.ExpressionElementRole,
4060 expr,
4061 )
4062 col_expr = col_expr.self_group()
4063 return CollectionAggregate(
4064 col_expr,
4065 operator=operators.any_op,
4066 type_=type_api.BOOLEANTYPE,
4067 )
4068
4069 @classmethod
4070 def _create_all(
4071 cls, expr: _ColumnExpressionArgument[_T]
4072 ) -> CollectionAggregate[bool]:
4073 """create CollectionAggregate for the legacy
4074 ARRAY.Comparator.all() method"""
4075 col_expr: ColumnElement[_T] = coercions.expect(
4076 roles.ExpressionElementRole,
4077 expr,
4078 )
4079 col_expr = col_expr.self_group()
4080 return CollectionAggregate(
4081 col_expr,
4082 operator=operators.all_op,
4083 type_=type_api.BOOLEANTYPE,
4084 )
4085
4086 @util.preload_module("sqlalchemy.sql.sqltypes")
4087 def _bind_param(
4088 self,
4089 operator: operators.OperatorType,
4090 obj: Any,
4091 type_: Optional[TypeEngine[_T]] = None,
4092 expanding: bool = False,
4093 ) -> BindParameter[_T]:
4094 """For new style any_(), all_(), ensure compared literal value
4095 receives appropriate bound parameter type."""
4096

Callers 2

_create_anyMethod · 0.85
_create_allMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected