MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / insert_data

Method insert_data

test/orm/test_joins.py:2995–3033  ·  view source on GitHub ↗
(cls, connection)

Source from the content-addressed store, hash-verified

2993
2994 @classmethod
2995 def insert_data(cls, connection):
2996 Node, nodes, node_to_nodes = (
2997 cls.classes.Node,
2998 cls.tables.nodes,
2999 cls.tables.node_to_nodes,
3000 )
3001
3002 cls.mapper_registry.map_imperatively(
3003 Node,
3004 nodes,
3005 properties={
3006 "children": relationship(
3007 Node,
3008 lazy="select",
3009 secondary=node_to_nodes,
3010 primaryjoin=nodes.c.id == node_to_nodes.c.left_node_id,
3011 secondaryjoin=nodes.c.id == node_to_nodes.c.right_node_id,
3012 )
3013 },
3014 )
3015 sess = Session(connection)
3016 n1 = Node(data="n1")
3017 n2 = Node(data="n2")
3018 n3 = Node(data="n3")
3019 n4 = Node(data="n4")
3020 n5 = Node(data="n5")
3021 n6 = Node(data="n6")
3022 n7 = Node(data="n7")
3023
3024 n1.children = [n2, n3, n4]
3025 n2.children = [n3, n6, n7]
3026 n3.children = [n5, n4]
3027
3028 sess.add(n1)
3029 sess.add(n2)
3030 sess.add(n3)
3031 sess.add(n4)
3032 sess.flush()
3033 sess.close()
3034
3035 def test_any(self):
3036 Node = self.classes.Node

Callers

nothing calls this directly

Calls 7

addMethod · 0.95
flushMethod · 0.95
closeMethod · 0.95
relationshipFunction · 0.90
SessionClass · 0.90
map_imperativelyMethod · 0.80
NodeClass · 0.70

Tested by

no test coverage detected