MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / test_hybrid_descriptor_two

Method test_hybrid_descriptor_two

test/orm/test_utils.py:318–342  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

316 )
317
318 def test_hybrid_descriptor_two(self):
319 class Point:
320 def __init__(self, x, y):
321 self.x, self.y = x, y
322
323 @hybrid_property
324 def double_x(self):
325 return self.x * 2
326
327 self._fixture(Point)
328 alias = aliased(Point)
329
330 eq_(str(Point.double_x), "Point.double_x")
331 eq_(str(alias.double_x), "aliased(Point).double_x")
332 eq_(str(Point.double_x.__clause_element__()), "point.x * :x_1")
333 eq_(str(alias.double_x.__clause_element__()), "point_1.x * :x_1")
334
335 sess = fixture_session()
336
337 self.assert_compile(
338 sess.query(alias).filter(alias.double_x > Point.x),
339 "SELECT point_1.id AS point_1_id, point_1.x AS point_1_x, "
340 "point_1.y AS point_1_y FROM point AS point_1, point "
341 "WHERE point_1.x * :x_1 > point.x",
342 )
343
344 def test_hybrid_descriptor_three(self):
345 class Point:

Callers

nothing calls this directly

Calls 8

_fixtureMethod · 0.95
aliasedFunction · 0.90
eq_Function · 0.90
fixture_sessionFunction · 0.90
assert_compileMethod · 0.80
__clause_element__Method · 0.45
filterMethod · 0.45
queryMethod · 0.45

Tested by

no test coverage detected