-
Notifications
You must be signed in to change notification settings - Fork 52
Open
Description
Hey @ben-ng, it's been a while, but I think I found a bug in eager-loading when using it with pagination!
If I have a bunch of posts and their users, and I want to paginate, I might make a query like this:
geddy.model.Post.all({}, {includes:'Person', limit:100, skip:100, sort:{createdAt:'desc'}}, callback);
which will first fetch the IDs of the relevant posts in an appropriate way, something like:
select post.id, post.createdAt from posts limit 100 skip 100 order by post.createdAt desc;
Which is working fine. The problem is that currently, the follow-up detail request KEEPS the offset, even when querying by ID, which means it skips all the correct results, and returns an empty array:
select post.*, person.* from posts post left outer join people person where ID in (1, 2, 3, 4,...)
ORDER BY post.created_at DESC, OFFSET 100;
This breaks pagination when using eager loaded associations! I think I've boiled it down it should be a quick fix, so I might take a look in there, but I'm sure it would be easier for someone who already has worked with this.
Metadata
Metadata
Assignees
Labels
No labels