vapor / fluent-kit

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

Allow eager-loading of deleted models #555

Closed tarag closed 1 year ago

tarag commented 1 year ago

Allows eager-loading of soft-deleted models. For maximum flexibility, choosing whether to load soft-deleted models or not is performed for each relation at each query call.

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

Use of default argument value of false requires no change to existing code to keep existing behaviour.

Fixes #375.

gwynne commented 1 year ago

Looks from the unit tests like you also need to update the complex join operators unit test (the one in FluentKitTests, not FluentBenchmark).

tarag commented 1 year ago

Thanks for the help, I committed your changes and added the necessary fixes to FluentKitTests.

codecov-commenter commented 1 year ago

Codecov Report

Merging #555 (3b073a4) into main (dd6b7f8) will decrease coverage by 0.03%. The diff coverage is 0.00%.

:exclamation: Current head 3b073a4 differs from pull request most recent head 873e542. Consider uploading reports for the commit 873e542 to get more accurate results

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #555 +/- ## ========================================== - Coverage 47.14% 47.11% -0.03% ========================================== Files 106 106 Lines 6147 6191 +44 ========================================== + Hits 2898 2917 +19 - Misses 3249 3274 +25 ``` | [Impacted Files](https://codecov.io/gh/vapor/fluent-kit/pull/555?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=vapor) | Coverage Δ | | |---|---|---| | [Sources/FluentKit/Model/EagerLoad.swift](https://codecov.io/gh/vapor/fluent-kit/pull/555?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=vapor#diff-U291cmNlcy9GbHVlbnRLaXQvTW9kZWwvRWFnZXJMb2FkLnN3aWZ0) | `0.00% <0.00%> (ø)` | | | [Sources/FluentKit/Properties/Children.swift](https://codecov.io/gh/vapor/fluent-kit/pull/555?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=vapor#diff-U291cmNlcy9GbHVlbnRLaXQvUHJvcGVydGllcy9DaGlsZHJlbi5zd2lmdA==) | `41.00% <0.00%> (-0.91%)` | :arrow_down: | | [...urces/FluentKit/Properties/CompositeChildren.swift](https://codecov.io/gh/vapor/fluent-kit/pull/555?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=vapor#diff-U291cmNlcy9GbHVlbnRLaXQvUHJvcGVydGllcy9Db21wb3NpdGVDaGlsZHJlbi5zd2lmdA==) | `46.75% <0.00%> (ø)` | | | [.../FluentKit/Properties/CompositeOptionalChild.swift](https://codecov.io/gh/vapor/fluent-kit/pull/555?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=vapor#diff-U291cmNlcy9GbHVlbnRLaXQvUHJvcGVydGllcy9Db21wb3NpdGVPcHRpb25hbENoaWxkLnN3aWZ0) | `41.77% <0.00%> (-1.09%)` | :arrow_down: | | [...FluentKit/Properties/CompositeOptionalParent.swift](https://codecov.io/gh/vapor/fluent-kit/pull/555?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=vapor#diff-U291cmNlcy9GbHVlbnRLaXQvUHJvcGVydGllcy9Db21wb3NpdGVPcHRpb25hbFBhcmVudC5zd2lmdA==) | `50.00% <0.00%> (-1.49%)` | :arrow_down: | | [Sources/FluentKit/Properties/CompositeParent.swift](https://codecov.io/gh/vapor/fluent-kit/pull/555?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=vapor#diff-U291cmNlcy9GbHVlbnRLaXQvUHJvcGVydGllcy9Db21wb3NpdGVQYXJlbnQuc3dpZnQ=) | `34.73% <0.00%> (-1.14%)` | :arrow_down: | | [Sources/FluentKit/Properties/OptionalChild.swift](https://codecov.io/gh/vapor/fluent-kit/pull/555?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=vapor#diff-U291cmNlcy9GbHVlbnRLaXQvUHJvcGVydGllcy9PcHRpb25hbENoaWxkLnN3aWZ0) | `23.80% <0.00%> (-0.59%)` | :arrow_down: | | [Sources/FluentKit/Properties/OptionalParent.swift](https://codecov.io/gh/vapor/fluent-kit/pull/555?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=vapor#diff-U291cmNlcy9GbHVlbnRLaXQvUHJvcGVydGllcy9PcHRpb25hbFBhcmVudC5zd2lmdA==) | `32.00% <0.00%> (-1.34%)` | :arrow_down: | | [Sources/FluentKit/Properties/Parent.swift](https://codecov.io/gh/vapor/fluent-kit/pull/555?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=vapor#diff-U291cmNlcy9GbHVlbnRLaXQvUHJvcGVydGllcy9QYXJlbnQuc3dpZnQ=) | `43.01% <0.00%> (-1.44%)` | :arrow_down: | | [Sources/FluentKit/Properties/Siblings.swift](https://codecov.io/gh/vapor/fluent-kit/pull/555?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=vapor#diff-U291cmNlcy9GbHVlbnRLaXQvUHJvcGVydGllcy9TaWJsaW5ncy5zd2lmdA==) | `49.05% <0.00%> (-0.71%)` | :arrow_down: | | ... and [1 more](https://codecov.io/gh/vapor/fluent-kit/pull/555?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=vapor) | | ... and [9 files with indirect coverage changes](https://codecov.io/gh/vapor/fluent-kit/pull/555/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=vapor)
VaporBot commented 1 year ago

These changes are now available in 1.41.0