(self)
| 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 = ( |
| 2514 | self.tables.a, |
| 2515 | self.classes.A, |
| 2516 | self.classes.B, |
| 2517 | self.tables.b, |
| 2518 | self.tables.atob, |
| 2519 | ) |
| 2520 | |
| 2521 | self.mapper_registry.map_imperatively( |
| 2522 | A, |
| 2523 | a, |
| 2524 | # if no backref here, delete-orphan |
| 2525 | properties={ |
| 2526 | "bs": relationship( |
| 2527 | B, |
| 2528 | secondary=atob, |
| 2529 | cascade="all, delete-orphan", |
| 2530 | single_parent=True, |
| 2531 | lazy="dynamic", |
| 2532 | ) |
| 2533 | }, |
| 2534 | ) |
| 2535 | # failed until [ticket:427] was fixed |
| 2536 | self.mapper_registry.map_imperatively(B, b) |
| 2537 | |
| 2538 | sess = fixture_session() |
| 2539 | b1 = B(data="b1") |
| 2540 | a1 = A(data="a1", bs=[b1]) |
| 2541 | sess.add(a1) |
| 2542 | sess.flush() |
| 2543 | |
| 2544 | a1.bs.remove(b1) |
| 2545 | sess.flush() |
| 2546 | eq_( |
| 2547 | sess.execute(select(func.count("*")).select_from(atob)).scalar(), 0 |
| 2548 | ) |
| 2549 | eq_(sess.execute(select(func.count("*")).select_from(b)).scalar(), 0) |
| 2550 | eq_(sess.execute(select(func.count("*")).select_from(a)).scalar(), 1) |
| 2551 | |
| 2552 | def test_delete_orphan_cascades(self): |
| 2553 | a, A, c, b, C, B, atob = ( |
nothing calls this directly
no test coverage detected