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

Add support for queryset slicing #1341

Merged
merged 1 commit into from
Apr 27, 2024

Conversation

yuvalbenarie
Copy link
Contributor

@yuvalbenarie yuvalbenarie commented Feb 15, 2023

Description

Add syntactic sugar in the form for queryset slicing, to enable qs[x:y] instead of qs.offset(x).limit(y-x)

Motivation and Context

This change brings us a bit closer to being Django-compatible.
The feature is used extensively by paginators in the form of qs[page_count*page_size:(page_count+1)*page_size].

How Has This Been Tested?

Added new tests to compare the new functionality against existing comparable operations.

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added the changelog accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@yuvalbenarie
Copy link
Contributor Author

I did not find documentation for limit and offset, so I wasn't sure how this should be documented and where.
Also, I am not sure how the CHANGELOG works here. Is it updated every X merged PRs, or am I supposed to open a new version/add myself to an existing version?

@long2ice
Copy link
Member

Thanks! Please resolve conflicts and update changelog

@yuvalbenarie
Copy link
Contributor Author

@long2ice Done and done.

@long2ice
Copy link
Member

Need style fix

@yuvalbenarie
Copy link
Contributor Author

@long2ice Fixed style.

@yuvalbenarie yuvalbenarie force-pushed the feature/queryset-slicing branch from 6158fac to d4846cc Compare April 27, 2024 15:02
@yuvalbenarie yuvalbenarie force-pushed the feature/queryset-slicing branch from d4846cc to 08a6cb6 Compare April 27, 2024 16:27
@coveralls
Copy link

Pull Request Test Coverage Report for Build 8861152030

Details

  • 13 of 14 (92.86%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.01%) to 87.934%

Changes Missing Coverage Covered Lines Changed/Added Lines %
tortoise/queryset.py 13 14 92.86%
Totals Coverage Status
Change from base Build 8859082359: 0.01%
Covered Lines: 5771
Relevant Lines: 6467

💛 - Coveralls

@abondar abondar merged commit c619625 into tortoise:develop Apr 27, 2024
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants