(self)
| 2470 | pass |
| 2471 | |
| 2472 | def test_delete_orphan(self): |
| 2473 | a, A, B, b, atob = ( |
| 2474 | self.tables.a, |
| 2475 | self.classes.A, |
| 2476 | self.classes.B, |
| 2477 | self.tables.b, |
| 2478 | self.tables.atob, |
| 2479 | ) |
| 2480 | |
| 2481 | # if no backref here, delete-orphan failed until [ticket:427] |
| 2482 | # was fixed |
| 2483 | |
| 2484 | self.mapper_registry.map_imperatively( |
| 2485 | A, |
| 2486 | a, |
| 2487 | properties={ |
| 2488 | "bs": relationship( |
| 2489 | B, |
| 2490 | secondary=atob, |
| 2491 | cascade="all, delete-orphan", |
| 2492 | single_parent=True, |
| 2493 | ) |
| 2494 | }, |
| 2495 | ) |
| 2496 | self.mapper_registry.map_imperatively(B, b) |
| 2497 | |
| 2498 | sess = fixture_session() |
| 2499 | b1 = B(data="b1") |
| 2500 | a1 = A(data="a1", bs=[b1]) |
| 2501 | sess.add(a1) |
| 2502 | sess.flush() |
| 2503 | |
| 2504 | a1.bs.remove(b1) |
| 2505 | sess.flush() |
| 2506 | eq_( |
| 2507 | sess.execute(select(func.count("*")).select_from(atob)).scalar(), 0 |
| 2508 | ) |
| 2509 | eq_(sess.execute(select(func.count("*")).select_from(b)).scalar(), 0) |
| 2510 | eq_(sess.execute(select(func.count("*")).select_from(a)).scalar(), 1) |
| 2511 | |
| 2512 | def test_delete_orphan_dynamic(self): |
| 2513 | a, A, B, b, atob = ( |
nothing calls this directly
no test coverage detected