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

Class CollectionAggregate

lib/sqlalchemy/sql/elements.py:3754–3852  ·  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

3752
3753
3754class CollectionAggregate(UnaryExpression[_T]):
3755 """Forms the basis for right-hand collection operator modifiers
3756 ANY and ALL.
3757
3758 The ANY and ALL keywords are available in different ways on different
3759 backends. On PostgreSQL, they only work for an ARRAY type. On
3760 MySQL, they only work for subqueries.
3761
3762 """
3763
3764 inherit_cache = True
3765 _is_collection_aggregate = True
3766
3767 @classmethod
3768 def _create_any(
3769 cls, expr: _ColumnExpressionArgument[_T]
3770 ) -> CollectionAggregate[bool]:
3771 """create CollectionAggregate for the legacy
3772 ARRAY.Comparator.any() method"""
3773 col_expr: ColumnElement[_T] = coercions.expect(
3774 roles.ExpressionElementRole,
3775 expr,
3776 )
3777 col_expr = col_expr.self_group()
3778 return CollectionAggregate(
3779 col_expr,
3780 operator=operators.any_op,
3781 type_=type_api.BOOLEANTYPE,
3782 )
3783
3784 @classmethod
3785 def _create_all(
3786 cls, expr: _ColumnExpressionArgument[_T]
3787 ) -> CollectionAggregate[bool]:
3788 """create CollectionAggregate for the legacy
3789 ARRAY.Comparator.all() method"""
3790 col_expr: ColumnElement[_T] = coercions.expect(
3791 roles.ExpressionElementRole,
3792 expr,
3793 )
3794 col_expr = col_expr.self_group()
3795 return CollectionAggregate(
3796 col_expr,
3797 operator=operators.all_op,
3798 type_=type_api.BOOLEANTYPE,
3799 )
3800
3801 @util.preload_module("sqlalchemy.sql.sqltypes")
3802 def _bind_param(
3803 self,
3804 operator: operators.OperatorType,
3805 obj: Any,
3806 type_: Optional[TypeEngine[_T]] = None,
3807 expanding: bool = False,
3808 ) -> BindParameter[_T]:
3809 """For new style any_(), all_(), ensure compared literal value
3810 receives appropriate bound parameter type."""
3811

Callers 2

_create_anyMethod · 0.85
_create_allMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected