vapor / fluent-kit

Swift ORM (queries, models, and relations) for NoSQL and SQL databases
MIT License
217 stars 116 forks source link

Added support for eager loading of soft deleted relations. #558

Closed maciejtrybilo closed 1 year ago

maciejtrybilo commented 1 year ago

This change adds withDeleted: Bool parameter to the with() query building function. For example:

let galaxies = try Galaxy.query(on: self.database)
  .with(\.$stars, withDeleted: true)
  .all()

will also return stars that are soft deleted.

There are a few tests that I'd still add in EagerLoadTests, but I would like to check with the maintainers if such an approach would be welcome.

Technically it’s a breaking change as it adds the withDeleted property to the public EagerLoader protocol. In practice It seems to me few clients would be implementing it, so it shouldn't cause much grief if any.

maciejtrybilo commented 1 year ago

I've been on it for a good while and just noticed that there is https://github.com/vapor/fluent-kit/pull/555 open already. Please feel free to close!

tarag commented 1 year ago

It seems your proposal is more complete than mine since I stepped over the Through... loaders, and you have updated tests too.

If this is an issue, I have a non breaking-change where a new protocol is added for these withDeleted calls.

Anyway, I hope one of the other PR will move forward.

0xTim commented 1 year ago

Closing in favour of #555