Skip to content

New Eager Loading Bug! #249

@danfinlay

Description

@danfinlay

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

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions