Skip to content

Commit

Permalink
Removed conditional count from pagination
Browse files Browse the repository at this point in the history
Made pagination consistent and removed a bug whereby counting results which are less than the per_page limit is incorrect due to de-duplication.
  • Loading branch information
CoburnJoe committed Feb 18, 2020
1 parent db02fd4 commit 0a085e2
Showing 1 changed file with 0 additions and 5 deletions.
5 changes: 0 additions & 5 deletions flask_sqlalchemy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -499,13 +499,8 @@ def paginate(self, page=None, per_page=None, error_out=True, max_per_page=None,
if not items and page != 1 and error_out:
abort(404)

# No need to count if we're on the first page and there are fewer
# items than we expected or if count is disabled.

if not count:
total = None
elif page == 1 and len(items) < per_page:
total = len(items)
else:
total = self.order_by(None).count()

Expand Down

0 comments on commit 0a085e2

Please sign in to comment.