If I preload accociations using a query that joins the tables, the number of rows returned by the query may be more than the number of rows that are displayed. Kerosene correctly works out the number of rows to display, but then uses this to limit the rows in the query.
For example:
from p in Pet,
join: vb in VetBooking, on: p.id == vb.pet_id
preload: [vet_booking: vb],
select: {p, vb}
If you had 2 pets each with 2 bookings, the query would return 4 rows but only 2 rows should be displayed (one for each pet). Kerosene correctly works out there are 2 rows, but say per_page = 2 it would add limit 2 to the query, which could just return 1 pet on Page 1... since those 2 rows could be the bookings for 1 pet.
This can cause a number of issues:
- some expected results do not appear on any pages at all
- Some pages will show less than the max allowed per_page results, even though there are subsiquent pages
If I preload accociations using a query that joins the tables, the number of rows returned by the query may be more than the number of rows that are displayed. Kerosene correctly works out the number of rows to display, but then uses this to limit the rows in the query.
For example:
If you had 2 pets each with 2 bookings, the query would return 4 rows but only 2 rows should be displayed (one for each pet). Kerosene correctly works out there are 2 rows, but say per_page = 2 it would add
limit 2to the query, which could just return 1 pet on Page 1... since those 2 rows could be the bookings for 1 pet.This can cause a number of issues: