-
-
Notifications
You must be signed in to change notification settings - Fork 120
Partial fix for nested keypaths through @CompositeOptionalParent properties
#632
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…ferenced model's IDValue are never actually nil.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #632 +/- ##
==========================================
+ Coverage 24.22% 24.26% +0.03%
==========================================
Files 149 149
Lines 9348 9348
==========================================
+ Hits 2265 2268 +3
+ Misses 7083 7080 -3
🚀 New features to boost your workflow:
|
@CompositeOptionalParent properties@CompositeOptionalParent properties
…d isn't very useful)
0xTim
approved these changes
Mar 12, 2025
gwynne
added a commit
that referenced
this pull request
Apr 11, 2025
…operties (#632) * Fix @CompositeOptionalParent so that keypaths to properties of the referenced model's IDValue are never actually nil. * Update CI versions for Swift and databases, enable Musl and Android tests * Apply updated theme settings to DocC catalogs, update Swift version in README * Fix a couple of warnings in tests, use a non-libc-dependent version of sleep() in a test * Disable the fields property performance test (breaks Android tests and isn't very useful)
bwdmr
pushed a commit
to bwdmr/fluent-kit
that referenced
this pull request
Dec 17, 2025
…operties (vapor#632) * Fix @CompositeOptionalParent so that keypaths to properties of the referenced model's IDValue are never actually nil. * Update CI versions for Swift and databases, enable Musl and Android tests * Apply updated theme settings to DocC catalogs, update Swift version in README * Fix a couple of warnings in tests, use a non-libc-dependent version of sleep() in a test * Disable the fields property performance test (breaks Android tests and isn't very useful)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
These changes are now available in 1.50.4
As with
@CompositeParent, keypaths through@CompositeOptionalParentcan refer to properties of the target model's compositeIDValue. However, thesubscript(dynamicMember:)accessor of@CompositeOptionalParentwhich enables this functionality returns an optional value, and the result is alwaysnilif the relation has not been loaded.This was caused by an oversight during the original implementation of the composite relation properties: The accessor should not be returning an optional value, nor should the result ever be
nilregardless of whether or not the relation is loaded. We can't fix the fact that it returns an optional without breaking public API, so callers still have to add a!in the nested keypaths. But we can at least make the accessor useful by fixing it to never returnnil, which is what this PR does. A test is also included.Also updates the CI while we're at it.
Example (omits some boilerplate for brevity):