MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / test_ordering

Method test_ordering

test/orm/test_eager_relations.py:4576–4603  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

4574 )
4575
4576 def test_ordering(self):
4577 a, m2m, b = (self.tables.a, self.tables.m2m, self.tables.b)
4578
4579 class A(ComparableEntity):
4580 pass
4581
4582 class B(ComparableEntity):
4583 pass
4584
4585 self.mapper_registry.map_imperatively(
4586 A,
4587 a,
4588 properties={
4589 "bs": relationship(
4590 B, secondary=m2m, lazy="joined", order_by=m2m.c.id
4591 )
4592 },
4593 )
4594 self.mapper_registry.map_imperatively(B, b)
4595
4596 sess = fixture_session()
4597 eq_(
4598 sess.query(A).all(),
4599 [
4600 A(data="a1", bs=[B(data="b3"), B(data="b1"), B(data="b2")]),
4601 A(bs=[B(data="b4"), B(data="b3"), B(data="b2")]),
4602 ],
4603 )
4604
4605
4606class SelfReferentialEagerTest(fixtures.MappedTest):

Callers

nothing calls this directly

Calls 8

relationshipFunction · 0.90
fixture_sessionFunction · 0.90
eq_Function · 0.90
map_imperativelyMethod · 0.80
AClass · 0.70
BClass · 0.70
allMethod · 0.45
queryMethod · 0.45

Tested by

no test coverage detected