Skip to content

Preloaded associations with joins #44

Description

@mbernerslee

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions