-
Notifications
You must be signed in to change notification settings - Fork 90
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
Pagination does not work with joins #59
Comments
Related Ecto issue; elixir-ecto/ecto#2926 |
@AndrewDryga is this still an issue? Or did the fix for the related Ecto issue fix the issue in Paginator as well? |
@bencoppock this is still an issue, internally we use our own fork of paginator that removes Ecto preloads for all one-to-many assocs when they are made on a paginated query and preloads them after the request in separate queries. But the best solution would be to construct a proper query that doesn't break with pagination. It's important to notice that this library is probably still the best one our community has at the moment, so if you looking for one - use it. Other pagination libs are using offset paging that doesn't scale and suffer from similar problems. |
Thanks, @AndrewDryga. Yeah, we definitely want keyset pagination as opposed to offset-based pagination, so that's what led me here. However, the fact that this library drops records with null in the cursor values is a non-starter for us unfortunately. I see that there's a fork called Quarto that fixes the |
@AndrewDryga, are you able to share the changes you made to |
@sgerrand we altered the paginator itself but for other purposes (having cursor on |
@bencoppock did you find a solution there? |
@glennr it's been a few months since I looked into this, and I'm just now about to get back into it. From what I recall, Quarto seemed an improvement (in that I believe it handled NULLs better), but it also had a couple issues that might block us from using it. Namely, when I last checked:
|
@bencoppock it does work with both of your use cases but I think the second one is out of scope for any pagination library.
If I remember correctly you can add
And it should not do it for you, but you still can do it yourself. From your example, you can |
If the query has joins, the limit you apply on a query would also count in a number of joined records. In result, you would get fewer results than you expect or, if there is a lot of joined records, one record without all joined assocs.
This is a classic error, which can be worked around like this:
But the library sets the limit by itself, which does not allow an application developer to wrap a query in a subquery.
The text was updated successfully, but these errors were encountered: