MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / BinaryExpression

Class BinaryExpression

lib/sqlalchemy/sql/elements.py:4165–4314  ·  view source on GitHub ↗

Represent an expression that is ``LEFT <operator> RIGHT``. A :class:`.BinaryExpression` is generated automatically whenever two column expressions are used in a Python binary expression: .. sourcecode:: pycon+sql >>> from sqlalchemy.sql import column >>> column("a") +

Source from the content-addressed store, hash-verified

4163
4164
4165class BinaryExpression(OperatorExpression[_T]):
4166 """Represent an expression that is ``LEFT <operator> RIGHT``.
4167
4168 A :class:`.BinaryExpression` is generated automatically
4169 whenever two column expressions are used in a Python binary expression:
4170
4171 .. sourcecode:: pycon+sql
4172
4173 >>> from sqlalchemy.sql import column
4174 >>> column("a") + column("b")
4175 <sqlalchemy.sql.expression.BinaryExpression object at 0x101029dd0>
4176 >>> print(column("a") + column("b"))
4177 {printsql}a + b
4178
4179 """
4180
4181 __visit_name__ = "binary"
4182
4183 _traverse_internals: _TraverseInternalsType = [
4184 ("left", InternalTraversal.dp_clauseelement),
4185 ("right", InternalTraversal.dp_clauseelement),
4186 ("operator", InternalTraversal.dp_operator),
4187 ("negate", InternalTraversal.dp_operator),
4188 ("modifiers", InternalTraversal.dp_plain_dict),
4189 (
4190 "type",
4191 InternalTraversal.dp_type,
4192 ),
4193 ]
4194
4195 _cache_key_traversal = [
4196 ("left", InternalTraversal.dp_clauseelement),
4197 ("right", InternalTraversal.dp_clauseelement),
4198 ("operator", InternalTraversal.dp_operator),
4199 ("modifiers", InternalTraversal.dp_plain_dict),
4200 # "type" affects JSON CAST operators, so while redundant in most cases,
4201 # is needed for that one
4202 (
4203 "type",
4204 InternalTraversal.dp_type,
4205 ),
4206 ]
4207
4208 _is_implicitly_boolean = True
4209 """Indicates that any database will know this is a boolean expression
4210 even if the database does not have an explicit boolean datatype.
4211
4212 """
4213
4214 left: ColumnElement[Any]
4215 right: ColumnElement[Any]
4216 modifiers: Mapping[str, Any]
4217
4218 def __init__(
4219 self,
4220 left: ColumnElement[Any],
4221 right: ColumnElement[Any],
4222 operator: OperatorType,

Callers 11

_construct_for_opMethod · 0.85
_negateMethod · 0.85
_between_implFunction · 0.85
_regexp_match_implFunction · 0.85
_regexp_replace_implFunction · 0.85
test_operateMethod · 0.85
test_inMethod · 0.85
test_not_inMethod · 0.85

Calls

no outgoing calls

Tested by 5

test_operateMethod · 0.68
test_inMethod · 0.68
test_not_inMethod · 0.68