(
cls,
left: ColumnElement[Any],
right: ColumnElement[Any],
op: OperatorType,
*,
type_: TypeEngine[_T],
negate: Optional[OperatorType] = None,
modifiers: Optional[Mapping[str, Any]] = None,
)
| 3152 | |
| 3153 | @classmethod |
| 3154 | def _construct_for_op( |
| 3155 | cls, |
| 3156 | left: ColumnElement[Any], |
| 3157 | right: ColumnElement[Any], |
| 3158 | op: OperatorType, |
| 3159 | *, |
| 3160 | type_: TypeEngine[_T], |
| 3161 | negate: Optional[OperatorType] = None, |
| 3162 | modifiers: Optional[Mapping[str, Any]] = None, |
| 3163 | ) -> OperatorExpression[_T]: |
| 3164 | if operators.is_associative(op): |
| 3165 | assert ( |
| 3166 | negate is None |
| 3167 | ), f"negate not supported for associative operator {op}" |
| 3168 | |
| 3169 | multi = False |
| 3170 | if getattr( |
| 3171 | left, "operator", None |
| 3172 | ) is op and type_._compare_type_affinity(left.type): |
| 3173 | multi = True |
| 3174 | left_flattened = left._flattened_operator_clauses |
| 3175 | else: |
| 3176 | left_flattened = (left,) |
| 3177 | |
| 3178 | if getattr( |
| 3179 | right, "operator", None |
| 3180 | ) is op and type_._compare_type_affinity(right.type): |
| 3181 | multi = True |
| 3182 | right_flattened = right._flattened_operator_clauses |
| 3183 | else: |
| 3184 | right_flattened = (right,) |
| 3185 | |
| 3186 | if multi: |
| 3187 | return ExpressionClauseList._construct_for_list( |
| 3188 | op, |
| 3189 | type_, |
| 3190 | *(left_flattened + right_flattened), |
| 3191 | ) |
| 3192 | |
| 3193 | if left._is_collection_aggregate or right._is_collection_aggregate: |
| 3194 | negate = None |
| 3195 | |
| 3196 | return BinaryExpression( |
| 3197 | left, right, op, type_=type_, negate=negate, modifiers=modifiers |
| 3198 | ) |
| 3199 | |
| 3200 | |
| 3201 | class ExpressionClauseList(OperatorExpression[_T]): |
no test coverage detected