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
()
| 2301 | |
| 2302 | |
| 2303 | def clear_mappers() -> None: |
| 2304 | """Remove all mappers from all classes. |
| 2305 | |
| 2306 | .. versionchanged:: 1.4 This function now locates all |
| 2307 | :class:`_orm.registry` objects and calls upon the |
| 2308 | :meth:`_orm.registry.dispose` method of each. |
| 2309 | |
| 2310 | This function removes all instrumentation from classes and disposes |
| 2311 | of their associated mappers. Once called, the classes are unmapped |
| 2312 | and can be later re-mapped with new mappers. |
| 2313 | |
| 2314 | :func:`.clear_mappers` is *not* for normal use, as there is literally no |
| 2315 | valid usage for it outside of very specific testing scenarios. Normally, |
| 2316 | mappers are permanent structural components of user-defined classes, and |
| 2317 | are never discarded independently of their class. If a mapped class |
| 2318 | itself is garbage collected, its mapper is automatically disposed of as |
| 2319 | well. As such, :func:`.clear_mappers` is only for usage in test suites |
| 2320 | that reuse the same classes with different mappings, which is itself an |
| 2321 | extremely rare use case - the only such use case is in fact SQLAlchemy's |
| 2322 | own test suite, and possibly the test suites of other ORM extension |
| 2323 | libraries which intend to test various combinations of mapper construction |
| 2324 | upon a fixed set of classes. |
| 2325 | |
| 2326 | """ |
| 2327 | |
| 2328 | mapperlib._dispose_registries(mapperlib._all_registries(), False) |
| 2329 | |
| 2330 | |
| 2331 | # I would really like a way to get the Type[] here that shows up |
no outgoing calls