Skip to content

Commit

Permalink
Fix bug in tortoise.models.Model When a QuerySet uses the only func…
Browse files Browse the repository at this point in the history
…tion and then uses the print function to print the returned result, an AttributeError is generated
  • Loading branch information
gongchangku committed Sep 29, 2024
1 parent f1075f6 commit 5b1814c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ Fixed
- Fix mysql uuid compression bug (#1687)
- Fix comment for fk fields without constraint for mysql (#1679)
- Removed no_delay option for postgres, as it wasn't doing anything (#1677)
- Fix bug in `tortoise.models.Model` When a QuerySet uses the only function and then uses the print function to print the returned result, an AttributeError is generated. (#1723)

0.21.5 <../0.21.5>`_ - 2024-07-18
------
Expand Down
2 changes: 1 addition & 1 deletion tortoise/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -781,7 +781,7 @@ def __eq__(self, other: object) -> bool:
return type(other) is type(self) and self.pk == other.pk # type: ignore

def _get_pk_val(self) -> Any:
return getattr(self, self._meta.pk_attr)
return getattr(self, self._meta.pk_attr, None)

def _set_pk_val(self, value: Any) -> None:
setattr(self, self._meta.pk_attr, value)
Expand Down

0 comments on commit 5b1814c

Please sign in to comment.