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

Class BinaryExpression

lib/sqlalchemy/sql/elements.py:3880–4029  ·  view source on GitHub ↗

Represent an expression that is ``LEFT 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

3878
3879
3880class BinaryExpression(OperatorExpression[_T]):
3881 """Represent an expression that is ``LEFT <operator> RIGHT``.
3882
3883 A :class:`.BinaryExpression` is generated automatically
3884 whenever two column expressions are used in a Python binary expression:
3885
3886 .. sourcecode:: pycon+sql
3887
3888 >>> from sqlalchemy.sql import column
3889 >>> column("a") + column("b")
3890 <sqlalchemy.sql.expression.BinaryExpression object at 0x101029dd0>
3891 >>> print(column("a") + column("b"))
3892 {printsql}a + b
3893
3894 """
3895
3896 __visit_name__ = "binary"
3897
3898 _traverse_internals: _TraverseInternalsType = [
3899 ("left", InternalTraversal.dp_clauseelement),
3900 ("right", InternalTraversal.dp_clauseelement),
3901 ("operator", InternalTraversal.dp_operator),
3902 ("negate", InternalTraversal.dp_operator),
3903 ("modifiers", InternalTraversal.dp_plain_dict),
3904 (
3905 "type",
3906 InternalTraversal.dp_type,
3907 ),
3908 ]
3909
3910 _cache_key_traversal = [
3911 ("left", InternalTraversal.dp_clauseelement),
3912 ("right", InternalTraversal.dp_clauseelement),
3913 ("operator", InternalTraversal.dp_operator),
3914 ("modifiers", InternalTraversal.dp_plain_dict),
3915 # "type" affects JSON CAST operators, so while redundant in most cases,
3916 # is needed for that one
3917 (
3918 "type",
3919 InternalTraversal.dp_type,
3920 ),
3921 ]
3922
3923 _is_implicitly_boolean = True
3924 """Indicates that any database will know this is a boolean expression
3925 even if the database does not have an explicit boolean datatype.
3926
3927 """
3928
3929 left: ColumnElement[Any]
3930 right: ColumnElement[Any]
3931 modifiers: Mapping[str, Any]
3932
3933 def __init__(
3934 self,
3935 left: ColumnElement[Any],
3936 right: ColumnElement[Any],
3937 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