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