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

Method _bind_param

lib/sqlalchemy/sql/elements.py:3802–3830  ·  view source on GitHub ↗

For new style any_(), all_(), ensure compared literal value receives appropriate bound parameter type.

(
        self,
        operator: operators.OperatorType,
        obj: Any,
        type_: Optional[TypeEngine[_T]] = None,
        expanding: bool = False,
    )

Source from the content-addressed store, hash-verified

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
3812 # a CollectionAggregate is specific to ARRAY or int
3813 # only. So for ARRAY case, make sure we use correct element type
3814 sqltypes = util.preloaded.sql_sqltypes
3815 if self.element.type._type_affinity is sqltypes.ARRAY:
3816 compared_to_type = cast(
3817 sqltypes.ARRAY[Any], self.element.type
3818 ).item_type
3819 else:
3820 compared_to_type = self.element.type
3821
3822 return BindParameter(
3823 None,
3824 obj,
3825 _compared_to_operator=operator,
3826 type_=type_,
3827 _compared_to_type=compared_to_type,
3828 unique=True,
3829 expanding=expanding,
3830 )
3831
3832 # operate and reverse_operate are hardwired to
3833 # dispatch onto the type comparator directly, so that we can

Callers

nothing calls this directly

Calls 2

castFunction · 0.85
BindParameterClass · 0.85

Tested by

no test coverage detected