MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / test_method_integration

Method test_method_integration

test/ext/test_hybrid.py:1136–1153  ·  view source on GitHub ↗
(self, decl_base)

Source from the content-addressed store, hash-verified

1134 self.assert_compile(Person.name, "concat(:concat_1, person._name)")
1135
1136 def test_method_integration(self, decl_base):
1137 class A(decl_base):
1138 __tablename__ = "a"
1139 id = Column(Integer, primary_key=True)
1140 _value = Column("value", String)
1141
1142 @hybrid.hybrid_method
1143 def value(self, x):
1144 return int(self._value) + x
1145
1146 @value.inplace.expression
1147 def _value_expression(cls, value):
1148 return func.foo(cls._value, value) + value
1149
1150 a1 = A(_value="10")
1151 eq_(a1.value(5), 15)
1152
1153 self.assert_compile(A.value(column("q")), "foo(a.value, q) + q")
1154
1155 def test_property_unit(self):
1156 def one():

Callers

nothing calls this directly

Calls 5

valueMethod · 0.95
eq_Function · 0.90
columnFunction · 0.90
assert_compileMethod · 0.80
AClass · 0.70

Tested by

no test coverage detected