MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / test_many_to_one_only

Method test_many_to_one_only

test/orm/test_cycles.py:97–131  ·  view source on GitHub ↗

test that the circular dependency sort can assemble a many-to-one dependency processor when only the object on the "many" side is actually in the list of modified objects.

(self)

Source from the content-addressed store, hash-verified

95 sess.flush()
96
97 def test_many_to_one_only(self):
98 """
99
100 test that the circular dependency sort can assemble a many-to-one
101 dependency processor when only the object on the "many" side is
102 actually in the list of modified objects.
103
104 """
105
106 C1, t1 = self.classes.C1, self.tables.t1
107
108 self.mapper_registry.map_imperatively(
109 C1,
110 t1,
111 properties={
112 "parent": relationship(
113 C1,
114 primaryjoin=t1.c.parent_c1 == t1.c.c1,
115 remote_side=t1.c.c1,
116 )
117 },
118 )
119
120 c1 = C1()
121
122 sess = fixture_session()
123 sess.add(c1)
124 sess.flush()
125 sess.expunge_all()
126 c1 = sess.get(C1, c1.c1)
127 c2 = C1()
128 c2.parent = c1
129 sess.add(c2)
130 sess.flush()
131 assert c2.parent_c1 == c1.c1
132
133 def test_cycle(self):
134 C2, C1, t2, t1 = (

Callers

nothing calls this directly

Calls 8

relationshipFunction · 0.90
fixture_sessionFunction · 0.90
map_imperativelyMethod · 0.80
C1Class · 0.70
addMethod · 0.45
flushMethod · 0.45
expunge_allMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected