MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / test_delete_cascade_BtoA

Method test_delete_cascade_BtoA

test/orm/test_relationships.py:1749–1778  ·  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

1747 "save-update, delete, delete-orphan",
1748 )
1749 def test_delete_cascade_BtoA(self, cascade):
1750 """No 'blank the PK' error when the child is to
1751 be deleted as part of a cascade"""
1752
1753 tableB, A, B, tableA = (
1754 self.tables.tableB,
1755 self.classes.A,
1756 self.classes.B,
1757 self.tables.tableA,
1758 )
1759
1760 self.mapper_registry.map_imperatively(
1761 B,
1762 tableB,
1763 properties={
1764 "a": relationship(A, cascade=cascade, single_parent=True)
1765 },
1766 )
1767 self.mapper_registry.map_imperatively(A, tableA)
1768
1769 b1 = B()
1770 a1 = A()
1771 b1.a = a1
1772 with fixture_session() as sess:
1773 sess.add(b1)
1774 sess.flush()
1775 sess.delete(b1)
1776 sess.flush()
1777 assert a1 not in sess
1778 assert b1 not in sess
1779
1780 @testing.combinations(
1781 "save-update, delete",

Callers

nothing calls this directly

Calls 8

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

Tested by

no test coverage detected