tortoise / tortoise-orm

Familiar asyncio ORM for python, built with relations in mind
https://tortoise.github.io
Apache License 2.0
4.7k stars 391 forks source link

Implement `last` for querysets and models #1756

Closed ruitcatarino closed 3 weeks ago

ruitcatarino commented 3 weeks ago

Description

This implements the last (https://docs.djangoproject.com/en/5.1/ref/models/querysets/#last methods similar to Django.

Motivation and Context

Like I explained in the issue https://github.com/tortoise/tortoise-orm/issues/1753 I miss this method as someone coming from Django.

How Has This Been Tested?

Well I implemented tests to validate the usage of this method 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

==================================================================================================== short test summary info ====================================================================================================
FAILED tests/test_queryset.py::TestQueryset::test_delete_limit - tortoise.exceptions.OperationalError: near "LIMIT": syntax error
FAILED tests/test_queryset.py::TestQueryset::test_delete_limit_order_by - tortoise.exceptions.OperationalError: near "ORDER": syntax error
FAILED tests/test_queryset.py::TestQueryset::test_delete - tortoise.exceptions.OperationalError: near "ORDER": syntax error
FAILED tests/test_update.py::TestUpdate::test_update_with_limit_ordering - tortoise.exceptions.OperationalError: near "ORDER": syntax error
ERROR tests/test_default.py
ERROR tests/test_two_databases.py
4 failed, 1156 passed, 67 skipped, 4 xfailed, 20 warnings, 2 errors in 69.54s (0:01:09)
coveralls commented 3 weeks ago

Pull Request Test Coverage Report for Build 11646693216

Details


Changes Missing Coverage Covered Lines Changed/Added Lines %
tortoise/queryset.py 10 11 90.91%
<!-- Total: 13 14 92.86% -->
Totals Coverage Status
Change from base Build 11641255981: 0.005%
Covered Lines: 6025
Relevant Lines: 6650

💛 - Coveralls