MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / _binary_operate

Function _binary_operate

lib/sqlalchemy/sql/default_comparator.py:163–188  ·  view source on GitHub ↗
(
    expr: ColumnElement[Any],
    op: OperatorType,
    obj: roles.BinaryElementRole[Any],
    *,
    reverse: bool = False,
    result_type: Optional[TypeEngine[_T]] = None,
    **kw: Any,
)

Source from the content-addressed store, hash-verified

161
162
163def _binary_operate(
164 expr: ColumnElement[Any],
165 op: OperatorType,
166 obj: roles.BinaryElementRole[Any],
167 *,
168 reverse: bool = False,
169 result_type: Optional[TypeEngine[_T]] = None,
170 **kw: Any,
171) -> OperatorExpression[_T]:
172 coerced_obj = coercions.expect(
173 roles.BinaryElementRole, obj, expr=expr, operator=op
174 )
175
176 if reverse:
177 left, right = coerced_obj, expr
178 else:
179 left, right = expr, coerced_obj
180
181 if result_type is None:
182 op, result_type = left.comparator._adapt_expression(
183 op, right.comparator
184 )
185
186 return OperatorExpression._construct_for_op(
187 left, right, op, type_=result_type, modifiers=kw
188 )
189
190
191def _conjunction_operate(

Callers 2

_custom_op_operateFunction · 0.85
_getitem_implFunction · 0.85

Calls 2

_construct_for_opMethod · 0.80
_adapt_expressionMethod · 0.45

Tested by

no test coverage detected