def __matmul__(self, other: Any) -> ColumnElement[Any]: ...
+ def __rmatmul__(self, other: Any) -> ColumnElement[Any]: ...
+
@overload
def concat(self: _SQO[str], other: Any) -> ColumnElement[str]: ...
return self.operate(rshift, other)
def __matmul__(self, other: Any) -> ColumnOperators:
- """Implement the @ operator.
+ """Implement the ``@`` operator.
Not used by SQLAlchemy core, this is provided
for custom operator systems which want to use
"""
return self.operate(matmul, other)
+ def __rmatmul__(self, other: Any) -> ColumnOperators:
+ """Implement the ``@`` operator in reverse.
+
+ Not used by SQLAlchemy core, this is provided
+ for custom operator systems which want to use
+ @ as an extension point.
+ """
+ return self.reverse_operate(matmul, other)
+
def concat(self, other: Any) -> ColumnOperators:
"""Implement the 'concat' operator.
self.assert_compile(Column("x", MyType()) @ 5, "x -> :x_1")
+ def test_rmatmul(self):
+ class MyType(UserDefinedType):
+ cache_ok = True
+
+ class comparator_factory(UserDefinedType.Comparator):
+ def __rmatmul__(self, other):
+ return self.op("->")(other)
+
+ self.assert_compile(5 @ Column("x", MyType()), "x -> :x_1")
+
class JSONIndexOpTest(fixtures.TestBase, testing.AssertsCompiledSQL):
def setup_test(self):