optimize __same__

This commit is contained in:
collerek
2021-03-26 12:47:12 +01:00
parent db7ac905b2
commit 8f60593123

View File

@ -341,8 +341,11 @@ class NewBaseModel(pydantic.BaseModel, ModelTableProxy, metaclass=ModelMetaclass
return (
self._orm_id == other._orm_id
or (self.pk == other.pk and self.pk is not None)
or self.dict(exclude=self.extract_related_names())
== other.dict(exclude=other.extract_related_names())
or (
(self.pk is None and other.pk is None)
and self.dict(exclude=self.extract_related_names())
== other.dict(exclude=other.extract_related_names())
)
)
@classmethod