MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / test_cyclical

Method test_cyclical

test/orm/test_selectin_relations.py:790–823  ·  view source on GitHub ↗

A circular eager relationship breaks the cycle with a lazy loader

(self)

Source from the content-addressed store, hash-verified

788 )
789
790 def test_cyclical(self):
791 """A circular eager relationship breaks the cycle with a lazy loader"""
792
793 Address, addresses, users, User = (
794 self.classes.Address,
795 self.tables.addresses,
796 self.tables.users,
797 self.classes.User,
798 )
799
800 self.mapper_registry.map_imperatively(Address, addresses)
801 self.mapper_registry.map_imperatively(
802 User,
803 users,
804 properties=dict(
805 addresses=relationship(
806 Address,
807 lazy="selectin",
808 backref=sa.orm.backref("user", lazy="selectin"),
809 order_by=Address.id,
810 )
811 ),
812 )
813 is_(
814 sa.orm.class_mapper(User).get_property("addresses").lazy,
815 "selectin",
816 )
817 is_(sa.orm.class_mapper(Address).get_property("user").lazy, "selectin")
818
819 sess = fixture_session()
820 eq_(
821 self.static.user_address_result,
822 sess.query(User).order_by(User.id).all(),
823 )
824
825 def test_cyclical_explicit_join_depth(self):
826 """A circular eager relationship breaks the cycle with a lazy loader"""

Callers

nothing calls this directly

Calls 9

relationshipFunction · 0.90
is_Function · 0.90
fixture_sessionFunction · 0.90
eq_Function · 0.90
map_imperativelyMethod · 0.80
get_propertyMethod · 0.80
allMethod · 0.45
order_byMethod · 0.45
queryMethod · 0.45

Tested by

no test coverage detected