-
-
Notifications
You must be signed in to change notification settings - Fork 387
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
Implement latest
and earliest
methods for a queryset
#1754
Implement latest
and earliest
methods for a queryset
#1754
Conversation
tortoise/queryset.py
Outdated
:params field_name: The field name to order by. | ||
""" | ||
queryset = self._clone() | ||
if not ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please add few test about passing related fields there?
Like related_model__pub_date
I understand that it is not a prime usecase for that, but if we are supporting that behaviour - would be nice to have it covered
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added more tests to increase coverage, including testing the use of related fields tests/test_latest_earliest.py
Pull Request Test Coverage Report for Build 11637250951Warning: This coverage report may be inaccurate.This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.
Details
💛 - Coveralls |
This change was made following what is described in the Django documentation
Description
This implements the latest (https://docs.djangoproject.com/en/5.1/ref/models/querysets/#latest) and earliest (https://docs.djangoproject.com/en/5.1/ref/models/querysets/#earliest) methods similar to Django.
Motivation and Context
Like I explained in the issue #1753 I miss these two methods as someone coming from Django.
How Has This Been Tested?
Well I implemented tests to validate the usage of both and ran them with
make test
. I also did some local testing.Checklist:
The existing tests are not passing in the
develop
branch for me. But the new created tests are passing. I'll post the output of my tests here