MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / test_setnull_ondelete

Method test_setnull_ondelete

test/orm/test_cycles.py:167–187  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

165 sess.flush()
166
167 def test_setnull_ondelete(self):
168 C1, t1 = self.classes.C1, self.tables.t1
169
170 self.mapper_registry.map_imperatively(
171 C1, t1, properties={"children": relationship(C1)}
172 )
173
174 sess = fixture_session()
175 c1 = C1()
176 c2 = C1()
177 c1.children.append(c2)
178 sess.add(c1)
179 sess.flush()
180 assert c2.parent_c1 == c1.c1
181
182 sess.delete(c1)
183 sess.flush()
184 assert c2.parent_c1 is None
185
186 sess.expire_all()
187 assert c2.parent_c1 is None
188
189
190class SelfReferentialNoPKTest(fixtures.MappedTest):

Callers

nothing calls this directly

Calls 9

relationshipFunction · 0.90
fixture_sessionFunction · 0.90
map_imperativelyMethod · 0.80
C1Class · 0.70
appendMethod · 0.45
addMethod · 0.45
flushMethod · 0.45
deleteMethod · 0.45
expire_allMethod · 0.45

Tested by

no test coverage detected