test that a lazily loaded child object is not marked as an orphan
(self)
| 210 | ] == sess.query(User).all() |
| 211 | |
| 212 | def test_no_orphan(self): |
| 213 | """test that a lazily loaded child object is not marked as an orphan""" |
| 214 | |
| 215 | users, Address, addresses, User = ( |
| 216 | self.tables.users, |
| 217 | self.classes.Address, |
| 218 | self.tables.addresses, |
| 219 | self.classes.User, |
| 220 | ) |
| 221 | |
| 222 | self.mapper_registry.map_imperatively( |
| 223 | User, |
| 224 | users, |
| 225 | properties={ |
| 226 | "addresses": relationship( |
| 227 | Address, cascade="all,delete-orphan", lazy="select" |
| 228 | ) |
| 229 | }, |
| 230 | ) |
| 231 | self.mapper_registry.map_imperatively(Address, addresses) |
| 232 | |
| 233 | sess = fixture_session() |
| 234 | user = sess.get(User, 7) |
| 235 | assert getattr(User, "addresses").hasparent( |
| 236 | attributes.instance_state(user.addresses[0]), optimistic=True |
| 237 | ) |
| 238 | assert not sa.orm.class_mapper(Address)._is_orphan( |
| 239 | attributes.instance_state(user.addresses[0]) |
| 240 | ) |
| 241 | |
| 242 | def test_limit(self): |
| 243 | """test limit operations combined with lazy-load relationships.""" |
nothing calls this directly
no test coverage detected