MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / test_delete_cascade_AtoB

Method test_delete_cascade_AtoB

test/orm/test_relationships.py:1785–1811  ·  view source on GitHub ↗

No 'blank the PK' error when the child is to be deleted as part of a cascade

(self, cascade)

Source from the content-addressed store, hash-verified

1783 "save-update, delete, delete-orphan",
1784 )
1785 def test_delete_cascade_AtoB(self, cascade):
1786 """No 'blank the PK' error when the child is to
1787 be deleted as part of a cascade"""
1788
1789 tableB, A, B, tableA = (
1790 self.tables.tableB,
1791 self.classes.A,
1792 self.classes.B,
1793 self.tables.tableA,
1794 )
1795
1796 self.mapper_registry.map_imperatively(
1797 A, tableA, properties={"bs": relationship(B, cascade=cascade)}
1798 )
1799 self.mapper_registry.map_imperatively(B, tableB)
1800
1801 a1 = A()
1802 b1 = B()
1803 a1.bs.append(b1)
1804 with fixture_session() as sess:
1805 sess.add(a1)
1806 sess.flush()
1807
1808 sess.delete(a1)
1809 sess.flush()
1810 assert a1 not in sess
1811 assert b1 not in sess
1812
1813 def test_delete_manual_AtoB(self):
1814 tableB, A, B, tableA = (

Callers

nothing calls this directly

Calls 9

relationshipFunction · 0.90
fixture_sessionFunction · 0.90
map_imperativelyMethod · 0.80
AClass · 0.70
BClass · 0.70
appendMethod · 0.45
addMethod · 0.45
flushMethod · 0.45
deleteMethod · 0.45

Tested by

no test coverage detected