Remove all mappers from all classes. .. versionchanged:: 1.4 This function now locates all :class:`_orm.registry` objects and calls upon the :meth:`_orm.registry.dispose` method of each. This function removes all instrumentation from classes and disposes of their associa
()
| 2334 | |
| 2335 | |
| 2336 | def clear_mappers() -> None: |
| 2337 | """Remove all mappers from all classes. |
| 2338 | |
| 2339 | .. versionchanged:: 1.4 This function now locates all |
| 2340 | :class:`_orm.registry` objects and calls upon the |
| 2341 | :meth:`_orm.registry.dispose` method of each. |
| 2342 | |
| 2343 | This function removes all instrumentation from classes and disposes |
| 2344 | of their associated mappers. Once called, the classes are unmapped |
| 2345 | and can be later re-mapped with new mappers. |
| 2346 | |
| 2347 | :func:`.clear_mappers` is *not* for normal use, as there is literally no |
| 2348 | valid usage for it outside of very specific testing scenarios. Normally, |
| 2349 | mappers are permanent structural components of user-defined classes, and |
| 2350 | are never discarded independently of their class. If a mapped class |
| 2351 | itself is garbage collected, its mapper is automatically disposed of as |
| 2352 | well. As such, :func:`.clear_mappers` is only for usage in test suites |
| 2353 | that reuse the same classes with different mappings, which is itself an |
| 2354 | extremely rare use case - the only such use case is in fact SQLAlchemy's |
| 2355 | own test suite, and possibly the test suites of other ORM extension |
| 2356 | libraries which intend to test various combinations of mapper construction |
| 2357 | upon a fixed set of classes. |
| 2358 | |
| 2359 | """ |
| 2360 | |
| 2361 | mapperlib._dispose_registries(mapperlib._all_registries(), False) |
| 2362 | |
| 2363 | |
| 2364 | # I would really like a way to get the Type[] here that shows up |
no outgoing calls