Skip to content

Commit

Permalink
fix comparation of models with non-models
Browse files Browse the repository at this point in the history
Changes:

- fix comparation of models with non-models
- bump version
  • Loading branch information
devkral committed Dec 19, 2024
1 parent e4d079f commit 2099d4a
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 1 deletion.
6 changes: 6 additions & 0 deletions docs/release-notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ hide:

# Release Notes

## 0.24.1

### Fixed

- Comparation of a model with non-models.

## 0.24.0

### Added
Expand Down
2 changes: 1 addition & 1 deletion edgy/__init__.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 2 additions & 0 deletions edgy/core/db/models/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 9 additions & 0 deletions tests/models/test_model_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit 2099d4a

Please sign in to comment.