Skip to content

Commit 83bea22

Browse files
committed
Revert "Temporarily revert changes to verify that the tests pass"
This reverts commit be1202a.
1 parent be1202a commit 83bea22

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

sqlmodel/main.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -585,10 +585,24 @@ def get_config(name: str) -> Any:
585585
setattr(new_cls, "__abstract__", True) # noqa: B010
586586
return new_cls
587587

588-
# Temporarily revert changes to verify that the tests pass
589-
# Override SQLAlchemy, allow both SQLAlchemy and plain Pydantic models
590588
def __init__(
591589
cls, classname: str, bases: Tuple[type, ...], dict_: Dict[str, Any], **kw: Any
590+
) -> None:
591+
return cls.__do_init__(bases, dict_, kw) # type: ignore
592+
593+
def sqlmodel_rebuild(cls) -> None:
594+
reg = cls._sa_registry
595+
# clear any exisiting mappers for the cls
596+
managers = [m for m in reg._managers if m.class_ == cls]
597+
for m in managers:
598+
reg._dispose_manager_and_mapper(m)
599+
del reg._managers[m]
600+
601+
return cls.__do_init__(cls.__bases__, cls.__dict__, {}) # type: ignore
602+
603+
# Override SQLAlchemy, allow both SQLAlchemy and plain Pydantic models
604+
def __do_init__(
605+
cls, classname: str, bases: Tuple[type, ...], dict_: Dict[str, Any], **kw: Any
592606
) -> None:
593607
# Only one of the base classes (or the current one) should be a table model
594608
# this allows FastAPI cloning a SQLModel for the response_model without

0 commit comments

Comments
 (0)