mirror of
https://github.com/JohnEstropia/CoreStore.git
synced 2026-01-14 07:33:28 +01:00
Support for @propertyWrappers for CoreStoreObject properties #302
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @JohnEstropia on GitHub (Jan 10, 2020).
Originally assigned to: @JohnEstropia on GitHub.
In a future update, these
CoreStoreObjectpropertiesValue.Required,Value.OptionalTransformable.Required,Transformable.OptionalRelationship.ToOne,Relationship.ToManyOrdered,Relationship.ToManyUnorderedwill be deprecated in favor of these
@propertyWrapperimplementations:Field.Stored(replacement forValue.RequiredandValue.Optional)Field.Virtual(new, equivalent totransientversions ofValue.RequiredandValue.Optional)Field.Coded(replacement forTransformable.RequiredandTransformable.Optional, with additional support for custom encoders such as JSON)Field.Identifier(new)Field.Relationship(replacement forRelationship.ToOne,Relationship.ToManyOrdered, andRelationship.ToManyUnordered)Fieldtypes that are marked above as "replacement"s will be able to migrate directly from their old counterparts. So if you have a property declared now asyou can directly convert it to
when you are ready. They will be effectively equal to Core Data, and your
VersionLocks will remain intact.Note that this effectively forces you to use a different syntax for queries:
From<Person>.where(\.title == "Mr.")From<Person>.where(\.$title == "Mr.")Also a couple of advantages:
@propertyWrapperversions will be magnitudes performant and efficient than their current implementations. CurrentlyMirrorreflection is used a lot to inject theNSManagedObjectreference into the properties. With@propertyWrappers this will be synthesized by the compiler for us. (See https://github.com/apple/swift/pull/25884)@propertyWrapperversions, beingstructs, will give the compiler a lot more room for optimizations which were not possible before due to the need for mutable classes.The only disadvantage will be
@propertyWrappers(But the legacy ones will remain available for quite a while, so while it is recommended to migrate soon, no need to panic)
Post implementation ideas:
@JohnEstropia commented on GitHub (Mar 27, 2020):
Released now for version
7.1.0!Please check the release notes: https://github.com/JohnEstropia/CoreStore/releases/tag/7.1.0