diff --git a/docs/release-notes.md b/docs/release-notes.md index 0be4eeec..5250d112 100644 --- a/docs/release-notes.md +++ b/docs/release-notes.md @@ -6,6 +6,12 @@ hide: # Release Notes +## 0.24.1 + +### Fixed + +- Comparation of a model with non-models. + ## 0.24.0 ### Added diff --git a/edgy/__init__.py b/edgy/__init__.py index e354c06a..ffbd1cc1 100644 --- a/edgy/__init__.py +++ b/edgy/__init__.py @@ -1,6 +1,6 @@ from __future__ import annotations -__version__ = "0.24.0" +__version__ = "0.24.1" from typing import TYPE_CHECKING from ._monkay import Instance, create_monkay diff --git a/edgy/core/db/models/base.py b/edgy/core/db/models/base.py index fe38ecf8..7149ea0d 100644 --- a/edgy/core/db/models/base.py +++ b/edgy/core/db/models/base.py @@ -515,6 +515,8 @@ def __getattr__(self, name: str) -> Any: def __eq__(self, other: Any) -> bool: # if self.__class__ != other.__class__: # return False + if not isinstance(other, EdgyBaseModel): + return False # somehow meta gets regenerated, so just compare tablename and registry. if self.meta.registry is not other.meta.registry: return False diff --git a/tests/models/test_model_class.py b/tests/models/test_model_class.py index 33ec076b..ccbc598a 100644 --- a/tests/models/test_model_class.py +++ b/tests/models/test_model_class.py @@ -105,3 +105,12 @@ async def test_model_get(): same_user = await User.query.get(pk=user.id) assert same_user.id == user.id assert same_user.pk == user.pk + + +async def test_eq(): + user = await User.query.create(name="Test") + assert user == user + assert user != "" + assert not user.__eq__("") + assert user != User + assert not user.__eq__(User)