Skip to content

Apply requested ordering to only to new cursors#1555

Open
annehaley wants to merge 2 commits into
masterfrom
pinned-cursor-fix
Open

Apply requested ordering to only to new cursors#1555
annehaley wants to merge 2 commits into
masterfrom
pinned-cursor-fix

Conversation

@annehaley

Copy link
Copy Markdown
Contributor

This issue in Sentry has been occurring since the introduction of the PinnedFirstPagination class. The error ValueError("Cursor position does not match the current ordering.") is raised when an existing cursor is later passed pin_sort=True. This PR adjusts the logic in paginate_queryset such that we only adjust the ordering if we are creating a new cursor (if pagination.cursor.position is None). If the cursor already has a position, continue with the same ordering regardless of whether pin_sort=True is present in the current request.

This PR also adds a test to confirm that the error is no longer raised if we try to change the ordering on an existing cursor.

@annehaley
annehaley requested a review from danlamanna July 6, 2026 16:20
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.

1 participant