0.0.39 is dropping the class_registry variable from main without warnings #2024
-
First Check
Example Codeimport sqlmodel.main as _sm
from sqlalchemy.orm import registry as _SARegistry
from sqlmodel import SQLModel as _SQLModel
_orig_registry = _SQLModel._sa_registry # type: ignore[attr-defined]
_orig_class_registry = _sm.class_registryDescriptionWe were using the Operating SystemLinux Operating System DetailsNo response Project Version0.0.39 Python VersionNo response Additional ContextNo response |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
|
When I reviewed that PR I searched for |
Beta Was this translation helpful? Give feedback.
-
|
The reason it got dropped as "unused" is that it genuinely was. In 0.0.38 and earlier, class_registry = weakref.WeakValueDictionary() # type: ignoreNothing else in SQLModel ever wrote to it or read from it (grep the old The registry that actually holds your mapped classes by name (the one SQLAlchemy uses to resolve string relationship refs) is on the registry object, not the module: from sqlmodel import SQLModel
SQLModel._sa_registry._class_registry
# same object as sqlmodel.main.default_registry._class_registryThat's the live If instead you were only using |
Beta Was this translation helpful? Give feedback.
The reason it got dropped as "unused" is that it genuinely was. In 0.0.38 and earlier,
sqlmodel.main.class_registrywas just this, sitting at module scope:Nothing else in SQLModel ever wrote to it or read from it (grep the old
main.py, it appears exactly once), and it was never exported fromsqlmodel/__init__.py. So it was always an empty dict that no SQLModel code touched. If your BigQuery compat code was reading_sm.class_registryexpecting to find your mapped classes in there, it was getting an empty mapping the whole time.The registry that actually holds your mapped classes by name (the one SQLAlchemy uses to resolve str…