Skip to content

Fix: Pagination to consider limit value while .all() will keep returning all records #281

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions aredis_om/model/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -742,8 +742,12 @@ async def execute(self, exhaust_results=True):
# current offset plus `page_size`, until we stop getting results back.
query = query.copy(offset=query.offset + query.page_size)
_results = await query.execute(exhaust_results=False)
if not _results:
break
if exhaust_results:
Copy link
Contributor

Choose a reason for hiding this comment

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

Can these two statements combine?

    break

Copy link

Choose a reason for hiding this comment

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

Doesn't seem important enough to block merging this. @chayim Can you approve?
Or would you like me to create a new PR?

if not _results:
break
else:
if not _results or len(self._model_cache) >= query.limit:
break
self._model_cache += _results
return self._model_cache

Expand Down