test that when a lazy loader is set as a trigger on an object's attribute (at the attribute level, not the class level), a refresh() operation doesn't fire the lazy loader or create any problems
(self)
| 2171 | assert u.name == "jack" |
| 2172 | |
| 2173 | def test_refresh_with_lazy(self): |
| 2174 | """test that when a lazy loader is set as a trigger on an object's |
| 2175 | attribute (at the attribute level, not the class level), a refresh() |
| 2176 | operation doesn't fire the lazy loader or create any problems""" |
| 2177 | |
| 2178 | User, Address, addresses, users = ( |
| 2179 | self.classes.User, |
| 2180 | self.classes.Address, |
| 2181 | self.tables.addresses, |
| 2182 | self.tables.users, |
| 2183 | ) |
| 2184 | |
| 2185 | s = fixture_session() |
| 2186 | self.mapper_registry.map_imperatively( |
| 2187 | User, |
| 2188 | users, |
| 2189 | properties={ |
| 2190 | "addresses": relationship( |
| 2191 | self.mapper_registry.map_imperatively(Address, addresses) |
| 2192 | ) |
| 2193 | }, |
| 2194 | ) |
| 2195 | q = s.query(User).options(sa.orm.lazyload(User.addresses)) |
| 2196 | u = q.filter(users.c.id == 8).first() |
| 2197 | |
| 2198 | def go(): |
| 2199 | s.refresh(u) |
| 2200 | |
| 2201 | self.assert_sql_count(testing.db, go, 1) |
| 2202 | |
| 2203 | def test_refresh_with_eager(self): |
| 2204 | """test that a refresh/expire operation loads rows properly and sends |
nothing calls this directly
no test coverage detected