Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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 #1724

Merged
merged 1 commit into from
Sep 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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