A can't be deleted without B because B would have no PK value.
(self)
| 1646 | sess.commit() |
| 1647 | |
| 1648 | def test_no_delete_PK_AtoB(self): |
| 1649 | """A can't be deleted without B because B would have no PK value.""" |
| 1650 | |
| 1651 | tableB, A, B, tableA = ( |
| 1652 | self.tables.tableB, |
| 1653 | self.classes.A, |
| 1654 | self.classes.B, |
| 1655 | self.tables.tableA, |
| 1656 | ) |
| 1657 | |
| 1658 | self.mapper_registry.map_imperatively( |
| 1659 | A, |
| 1660 | tableA, |
| 1661 | properties={"bs": relationship(B, cascade="save-update")}, |
| 1662 | ) |
| 1663 | self.mapper_registry.map_imperatively(B, tableB) |
| 1664 | |
| 1665 | a1 = A() |
| 1666 | a1.bs.append(B()) |
| 1667 | with fixture_session() as sess: |
| 1668 | sess.add(a1) |
| 1669 | sess.flush() |
| 1670 | |
| 1671 | sess.delete(a1) |
| 1672 | |
| 1673 | assert_raises_message( |
| 1674 | AssertionError, |
| 1675 | "Dependency rule on column 'tableA.id' tried to blank-out " |
| 1676 | "primary key column 'tableB.id' on instance ", |
| 1677 | sess.flush, |
| 1678 | ) |
| 1679 | |
| 1680 | def test_no_delete_PK_BtoA(self): |
| 1681 | tableB, A, B, tableA = ( |
nothing calls this directly
no test coverage detected