Open danfinlay opened 9 years ago
Woah! Nice find, I'll take a look after work π
My guess is that this condition should be modified to say:
if (skip && !query.opts.includes) {
I might have time to check if that works after lunch. Haven't gotten Model's tests running locally somehow. Need to take the time.
Actually that could be the pre-query, not sure..
had an unusually long day at work, going to have to defer this to tomorrow π
ping me on twitter if i forget! i have it on my to-do list.
Yeah no hard feelings, I had a long day too. Hope you beat those tasks back soon!
I wrote a test for what I described, but it's passing. If I can't replicate this soon I'll just close it, maybe something else is going on.
These tests seem to suggest that having an offset of 2 will wrap around the set if there are only two results for the query.
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:
which will first fetch the IDs of the relevant posts in an appropriate way, something like:
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:
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.