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

Make OffsetQueryPagingSource only work with Int #3386

Conversation

veyndan
Copy link
Collaborator

@veyndan veyndan commented Jul 19, 2022

Breaking API change! Maybe it's okay as we're releasing SQLDelight 2 soon…

Previously, we're just upcasting state.anchorPosition to a Long, which screws things up when we have between Int.MAX_VALUE and Long.MAX_VALUE items in our pager. This is because, when we refresh the paging source, getRefreshKey(state: PagingState) is called, and we'll end up with a very wrong state.anchorPosition, as it's no longer the "most recently accessed index in the list", but some truncated form of it. The result of getRefresKey(…) will end up being passed to load(params: LoadParams) in the form of params.key, and bad things will happen as it's not the value we're expecting.

The "fix" is just to force a maximum of Int.MAX_VALUE items instead of Long.MAX_VALUE. Room does the same thing in their implementation of this class.

@veyndan veyndan force-pushed the veyndan/2022-07-19/OffsetQueryPagingSource-Int branch from 8f4a014 to a5bc1df Compare July 19, 2022 14:44
@AlecKazakova AlecKazakova merged commit d7b26dd into cashapp:master Jul 20, 2022
@veyndan veyndan deleted the veyndan/2022-07-19/OffsetQueryPagingSource-Int branch July 25, 2022 09:17
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