fix model_config SQLModel (#3457)

* fix model_config SQLModel

* added comment
This commit is contained in:
HRUSHIKESH DOKALA 2024-09-02 01:54:27 +05:30 committed by GitHub
parent 4577524994
commit ca1a89cb6b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 13 additions and 1 deletions

View File

@ -16,7 +16,19 @@ from sqlmodel import (
Enum as SqlEnum,
)
SQLModel.model_config["protected_namespaces"] = ()
# added for python3.11 and sqlmodel 0.0.22 incompatibility
if hasattr(SQLModel, "model_config"):
SQLModel.model_config["protected_namespaces"] = ()
elif hasattr(SQLModel, "Config"):
class CustomSQLModel(SQLModel):
class Config:
protected_namespaces = ()
SQLModel = CustomSQLModel
else:
print("Warning: Unable to set protected_namespaces.")
# pylint: disable=protected-access