MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / test_self_referential

Method test_self_referential

test/orm/test_dynamic.py:1212–1231  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1210 )
1211
1212 def test_self_referential(self):
1213 Node, nodes = self.classes.Node, self.tables.nodes
1214
1215 self.mapper_registry.map_imperatively(
1216 Node,
1217 nodes,
1218 properties={
1219 "children": relationship(
1220 Node, lazy="dynamic", order_by=nodes.c.id
1221 )
1222 },
1223 )
1224
1225 sess = fixture_session()
1226 n2, n3 = Node(), Node()
1227 n1 = Node(children=[n2, n3])
1228 sess.add(n1)
1229 sess.commit()
1230
1231 eq_(n1.children.all(), [n2, n3])
1232
1233 def test_remove_orphans(self, user_address_fixture):
1234 addresses = self.tables.addresses

Callers

nothing calls this directly

Calls 8

relationshipFunction · 0.90
fixture_sessionFunction · 0.90
eq_Function · 0.90
map_imperativelyMethod · 0.80
NodeClass · 0.70
addMethod · 0.45
commitMethod · 0.45
allMethod · 0.45

Tested by

no test coverage detected