local-ch / lhs

⚛️ REST services accelerator: Rails gem providing an easy, active-record-like interface for http (hypermedia) json services
GNU General Public License v3.0
137 stars 3 forks source link

includes_all is the new default `includes` #382

Closed 10xSebastian closed 4 years ago

10xSebastian commented 4 years ago

Addresses https://github.com/local-ch/lhs/issues/304

Since the very beginning, people seems to intuitively think includes is gonna include all linked resources, even if that link is paginated on it's own. Unfortunately that is/was never the case. In fact includes was only fetching and including the first page of the linked collection, while includes_all was making sure to paginate that collection and really include all of them.

This miss-understanding, or lack of - what it seems - to be an none-intuitive method interface in the first place usually leads to problems down the road once you hit edge-case in you application where records do have more then X linked items. Like places with hundreds of contracts, or places with hundreds of accounts etc.

This PR changes the defaults and makes includes include all linked resources even if it is paginated, and includes_first_page is explicitly only gonna include the first page of the linked collection.

Migration Path

  1. Replace all includes with includes_first_page
  2. Replace all includes_all with includes

Needs to be in this order 😉