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 incorrect total number in page when paginating beanie query with fetch_links=True #1199

Merged
merged 4 commits into from
Jun 24, 2024

Conversation

IterableTrucks
Copy link
Contributor

@IterableTrucks IterableTrucks commented Jun 18, 2024

Beanie's find_many method will modify the limit and offset number of the query. When querying with fetch_links=False as default, this will not be a problem, but when fetch_links=True the implicitly created aggregation pipeline will add limit and skip stages which is incorrect to count the total number. To fix this problem, count query should be placed before items query and the fetch_links should respect the parameter's value in paginate method.

@IterableTrucks IterableTrucks changed the title fix 0 total number in page when paginating beanie query with fetch_links=True fix incorrect total number in page when paginating beanie query with fetch_links=True Jun 18, 2024
Copy link

codecov bot commented Jun 20, 2024

Codecov Report

Attention: Patch coverage is 66.66667% with 1 line in your changes missing coverage. Please review.

Project coverage is 92.69%. Comparing base (245519c) to head (b76c621).
Report is 282 commits behind head on main.

Files Patch % Lines
fastapi_pagination/ext/beanie.py 66.66% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1199      +/-   ##
==========================================
- Coverage   93.26%   92.69%   -0.58%     
==========================================
  Files          35       38       +3     
  Lines        1040     1314     +274     
==========================================
+ Hits          970     1218     +248     
- Misses         70       96      +26     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@uriyyo
Copy link
Owner

uriyyo commented Jun 20, 2024

@IterableTrucks Could you please fix lint errors?

@uriyyo uriyyo merged commit 894b12b into uriyyo:main Jun 24, 2024
15 of 17 checks passed
Copy link
Owner

@uriyyo uriyyo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

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.

None yet

2 participants