Skip to content

Commit

Permalink
Revert "Temporarily revert changes to verify that the tests pass"
Browse files Browse the repository at this point in the history
This reverts commit be1202a.
  • Loading branch information
adsharma committed Feb 28, 2025
1 parent be1202a commit 83bea22
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions sqlmodel/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -585,10 +585,24 @@ def get_config(name: str) -> Any:
setattr(new_cls, "__abstract__", True) # noqa: B010
return new_cls

# Temporarily revert changes to verify that the tests pass
# Override SQLAlchemy, allow both SQLAlchemy and plain Pydantic models
def __init__(
cls, classname: str, bases: Tuple[type, ...], dict_: Dict[str, Any], **kw: Any
) -> None:
return cls.__do_init__(bases, dict_, kw) # type: ignore

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

return cls.__do_init__(cls.__bases__, cls.__dict__, {}) # type: ignore

# Override SQLAlchemy, allow both SQLAlchemy and plain Pydantic models
def __do_init__(
cls, classname: str, bases: Tuple[type, ...], dict_: Dict[str, Any], **kw: Any
) -> None:
# Only one of the base classes (or the current one) should be a table model
# this allows FastAPI cloning a SQLModel for the response_model without
Expand Down

0 comments on commit 83bea22

Please sign in to comment.