Skip to content

Commit

Permalink
registry: unregister the manager and class
Browse files Browse the repository at this point in the history
  • Loading branch information
adsharma committed Jan 17, 2025
1 parent 1c5263e commit 80f2935
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions sqlmodel/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -591,6 +591,14 @@ def __init__(
return cls.__do_init__(bases, dict_, kw)

def sqlmodel_rebuild(cls) -> None:
reg = cls._sa_registry
# clear any exisiting mappers for the cls
manager = [m for m in reg._managers if m.class_ == cls]
if len(manager) > 0:
for m in manager:
reg._dispose_manager_and_mapper(m)
del reg._managers[m]

return cls.__do_init__(cls.__bases__, cls.__dict__, {})

# Override SQLAlchemy, allow both SQLAlchemy and plain Pydantic models
Expand Down

0 comments on commit 80f2935

Please sign in to comment.