MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / test_reuse_expr

Method test_reuse_expr

test/orm/test_deferred.py:2310–2326  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

2308 )
2309
2310 def test_reuse_expr(self):
2311 A = self.classes.A
2312
2313 s = fixture_session()
2314
2315 # so people will obv. want to say, "filter(A.my_expr > 10)".
2316 # but that means Query or Core has to post-modify the statement
2317 # after construction.
2318 expr = A.x + A.y
2319 a1 = (
2320 s.query(A)
2321 .options(with_expression(A.my_expr, expr))
2322 .filter(expr > 10)
2323 .order_by(expr)
2324 )
2325
2326 eq_(a1.all(), [A(my_expr=12), A(my_expr=15)])
2327
2328 def test_in_joinedload(self):
2329 A, B = self.classes("A", "B")

Callers

nothing calls this directly

Calls 9

fixture_sessionFunction · 0.90
with_expressionFunction · 0.90
eq_Function · 0.90
AClass · 0.70
order_byMethod · 0.45
filterMethod · 0.45
optionsMethod · 0.45
queryMethod · 0.45
allMethod · 0.45

Tested by

no test coverage detected