| 2498 | ) |
| 2499 | |
| 2500 | def _is_orphan(self, state: InstanceState[_O]) -> bool: |
| 2501 | orphan_possible = False |
| 2502 | for mapper in self.iterate_to_root(): |
| 2503 | for key, cls in mapper._delete_orphans: |
| 2504 | orphan_possible = True |
| 2505 | |
| 2506 | has_parent = attributes.manager_of_class(cls).has_parent( |
| 2507 | state, key, optimistic=state.has_identity |
| 2508 | ) |
| 2509 | |
| 2510 | if self.legacy_is_orphan and has_parent: |
| 2511 | return False |
| 2512 | elif not self.legacy_is_orphan and not has_parent: |
| 2513 | return True |
| 2514 | |
| 2515 | if self.legacy_is_orphan: |
| 2516 | return orphan_possible |
| 2517 | else: |
| 2518 | return False |
| 2519 | |
| 2520 | def has_property(self, key: str) -> bool: |
| 2521 | return key in self._props |