add save status and tests
This commit is contained in:
@ -144,12 +144,12 @@ class NewBaseModel(
|
||||
|
||||
def __getattribute__(self, item: str) -> Any:
|
||||
if item in (
|
||||
"_orm_id",
|
||||
"_orm_saved",
|
||||
"_orm",
|
||||
"__fields__",
|
||||
"_related_names",
|
||||
"_props",
|
||||
"_orm_id",
|
||||
"_orm_saved",
|
||||
"_orm",
|
||||
"__fields__",
|
||||
"_related_names",
|
||||
"_props",
|
||||
):
|
||||
return object.__getattribute__(self, item)
|
||||
if item == "pk":
|
||||
@ -163,7 +163,7 @@ class NewBaseModel(
|
||||
return super().__getattribute__(item)
|
||||
|
||||
def _extract_related_model_instead_of_field(
|
||||
self, item: str
|
||||
self, item: str
|
||||
) -> Optional[Union["T", Sequence["T"]]]:
|
||||
# alias = self.get_column_alias(item)
|
||||
if item in self._orm:
|
||||
@ -177,9 +177,9 @@ class NewBaseModel(
|
||||
|
||||
def __same__(self, other: "NewBaseModel") -> bool:
|
||||
return (
|
||||
self._orm_id == other._orm_id
|
||||
or self.dict() == other.dict()
|
||||
or (self.pk == other.pk and self.pk is not None)
|
||||
self._orm_id == other._orm_id
|
||||
or self.dict() == other.dict()
|
||||
or (self.pk == other.pk and self.pk is not None)
|
||||
)
|
||||
|
||||
@classmethod
|
||||
@ -209,9 +209,9 @@ class NewBaseModel(
|
||||
|
||||
@classmethod
|
||||
def get_properties(
|
||||
cls,
|
||||
include: Union["AbstractSetIntStr", "MappingIntStrAny"] = None,
|
||||
exclude: Union["AbstractSetIntStr", "MappingIntStrAny"] = None,
|
||||
cls,
|
||||
include: Union["AbstractSetIntStr", "MappingIntStrAny"] = None,
|
||||
exclude: Union["AbstractSetIntStr", "MappingIntStrAny"] = None,
|
||||
) -> List[str]:
|
||||
if isinstance(cls._props, list):
|
||||
props = cls._props
|
||||
@ -220,7 +220,7 @@ class NewBaseModel(
|
||||
prop
|
||||
for prop in dir(cls)
|
||||
if isinstance(getattr(cls, prop), property)
|
||||
and prop not in ("__values__", "__fields__", "fields", "pk_column")
|
||||
and prop not in ("__values__", "__fields__", "fields", "pk_column")
|
||||
]
|
||||
cls._props = props
|
||||
if include:
|
||||
@ -230,16 +230,16 @@ class NewBaseModel(
|
||||
return props
|
||||
|
||||
def dict( # noqa A003
|
||||
self,
|
||||
*,
|
||||
include: Union["AbstractSetIntStr", "MappingIntStrAny"] = None,
|
||||
exclude: Union["AbstractSetIntStr", "MappingIntStrAny"] = None,
|
||||
by_alias: bool = False,
|
||||
skip_defaults: bool = None,
|
||||
exclude_unset: bool = False,
|
||||
exclude_defaults: bool = False,
|
||||
exclude_none: bool = False,
|
||||
nested: bool = False
|
||||
self,
|
||||
*,
|
||||
include: Union["AbstractSetIntStr", "MappingIntStrAny"] = None,
|
||||
exclude: Union["AbstractSetIntStr", "MappingIntStrAny"] = None,
|
||||
by_alias: bool = False,
|
||||
skip_defaults: bool = None,
|
||||
exclude_unset: bool = False,
|
||||
exclude_defaults: bool = False,
|
||||
exclude_none: bool = False,
|
||||
nested: bool = False
|
||||
) -> "DictStrAny": # noqa: A003'
|
||||
dict_instance = super().dict(
|
||||
include=include,
|
||||
|
||||
Reference in New Issue
Block a user