#485 add possibility to pass comments to sqlalchemy
This commit is contained in:
@ -195,6 +195,29 @@ class NewBaseModel(pydantic.BaseModel, ModelTableProxy, metaclass=ModelMetaclass
|
||||
"""
|
||||
return super().__getattribute__(item)
|
||||
|
||||
def __getstate__(self) -> Dict[Any, Any]:
|
||||
state = super().__getstate__()
|
||||
self_dict = self.dict()
|
||||
state["__dict__"].update(**self_dict)
|
||||
return state
|
||||
|
||||
def __setstate__(self, state: Dict[Any, Any]) -> None:
|
||||
relations = {
|
||||
k: v
|
||||
for k, v in state["__dict__"].items()
|
||||
if k in self.extract_related_names()
|
||||
}
|
||||
basic_state = {
|
||||
k: v
|
||||
for k, v in state["__dict__"].items()
|
||||
if k not in self.extract_related_names()
|
||||
}
|
||||
state["__dict__"] = basic_state
|
||||
super().__setstate__(state)
|
||||
self._initialize_internal_attributes()
|
||||
for name, value in relations.items():
|
||||
setattr(self, name, value)
|
||||
|
||||
def _internal_set(self, name: str, value: Any) -> None:
|
||||
"""
|
||||
Delegates call to pydantic.
|
||||
|
||||
Reference in New Issue
Block a user