MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / _bind_param

Method _bind_param

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

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
4097 # a CollectionAggregate is specific to ARRAY or int
4098 # only. So for ARRAY case, make sure we use correct element type
4099 sqltypes = util.preloaded.sql_sqltypes
4100 if self.element.type._type_affinity is sqltypes.ARRAY:
4101 compared_to_type = cast(
4102 sqltypes.ARRAY[Any], self.element.type
4103 ).item_type
4104 else:
4105 compared_to_type = self.element.type
4106
4107 return BindParameter(
4108 None,
4109 obj,
4110 _compared_to_operator=operator,
4111 type_=type_,
4112 _compared_to_type=compared_to_type,
4113 unique=True,
4114 expanding=expanding,
4115 )
4116
4117 # operate and reverse_operate are hardwired to
4118 # dispatch onto the type comparator directly, so that we can

Callers

nothing calls this directly

Calls 2

BindParameterClass · 0.85
castFunction · 0.70

Tested by

no test coverage detected