Skip to content

1.50.4 - Partial fix for nested keypaths through `@CompositeOptionalParent` properties

Latest
Compare
Choose a tag to compare
@penny-for-vapor penny-for-vapor released this 12 Mar 00:14
· 1 commit to main since this release
f12a668

What's Changed

Partial fix for nested keypaths through @CompositeOptionalParent properties by @gwynne in #632

As with @CompositeParent, keypaths through @CompositeOptionalParent can refer to properties of the target model’s composite IDValue. However, the subscript(dynamicMember:) accessor of @CompositeOptionalParent which enables this functionality returns an optional value, and the result is always nil if 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 nil regardless 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 return nil, which is what this PR does. A test is also included.

Also updates the CI while we’re at it.

final class ParentModel: Model, @unchecked Sendable {
    final class IDValue: Fields, @unc

This patch was released by @gwynne

Full Changelog: 1.50.3...1.50.4