@@ -121,49 +121,49 @@ public class CustomSchemaMappingProvider: Hashable, SchemaMappingProvider {
121121
122122 // MARK: Equatable
123123
124- public static func == ( lhs: CustomMapping , rhs: CustomMapping ) -> Bool {
124+ public static func == ( lhs: CustomMapping , rhs: CustomMapping ) -> Bool {
125125
126126 switch ( lhs, rhs) {
127-
127+
128128 case ( . deleteEntity( let sourceEntity1) , . deleteEntity( let sourceEntity2) ) :
129129 return sourceEntity1 == sourceEntity2
130-
130+
131131 case ( . insertEntity( let destinationEntity1) , . insertEntity( let destinationEntity2) ) :
132132 return destinationEntity1 == destinationEntity2
133-
133+
134134 case ( . copyEntity( let sourceEntity1, let destinationEntity1) , . copyEntity( let sourceEntity2, let destinationEntity2) ) :
135135 return sourceEntity1 == sourceEntity2
136136 && destinationEntity1 == destinationEntity2
137-
137+
138138 case ( . transformEntity( let sourceEntity1, let destinationEntity1, _) , . transformEntity( let sourceEntity2, let destinationEntity2, _) ) :
139139 return sourceEntity1 == sourceEntity2
140140 && destinationEntity1 == destinationEntity2
141-
141+
142142 default :
143143 return false
144144 }
145145 }
146146
147147
148148 // MARK: Hashable
149-
149+
150150 public func hash( into hasher: inout Hasher ) {
151151
152152 switch self {
153-
153+
154154 case . deleteEntity( let sourceEntity) :
155155 hasher. combine ( 0 )
156156 hasher. combine ( sourceEntity)
157-
157+
158158 case . insertEntity( let destinationEntity) :
159159 hasher. combine ( 1 )
160160 hasher. combine ( destinationEntity)
161-
161+
162162 case . copyEntity( let sourceEntity, let destinationEntity) :
163163 hasher. combine ( 2 )
164164 hasher. combine ( sourceEntity)
165165 hasher. combine ( destinationEntity)
166-
166+
167167 case . transformEntity( let sourceEntity, let destinationEntity, _) :
168168 hasher. combine ( 3 )
169169 hasher. combine ( sourceEntity)
@@ -177,12 +177,12 @@ public class CustomSchemaMappingProvider: Hashable, SchemaMappingProvider {
177177 fileprivate var entityMappingSourceEntity : EntityName ? {
178178
179179 switch self {
180-
180+
181181 case . deleteEntity( let sourceEntity) ,
182182 . copyEntity( let sourceEntity, _) ,
183183 . transformEntity( let sourceEntity, _, _) :
184184 return sourceEntity
185-
185+
186186 case . insertEntity:
187187 return nil
188188 }
@@ -191,12 +191,12 @@ public class CustomSchemaMappingProvider: Hashable, SchemaMappingProvider {
191191 fileprivate var entityMappingDestinationEntity : EntityName ? {
192192
193193 switch self {
194-
194+
195195 case . insertEntity( let destinationEntity) ,
196196 . copyEntity( _, let destinationEntity) ,
197197 . transformEntity( _, let destinationEntity, _) :
198198 return destinationEntity
199-
199+
200200 case . deleteEntity:
201201 return nil
202202 }
@@ -324,7 +324,7 @@ public class CustomSchemaMappingProvider: Hashable, SchemaMappingProvider {
324324
325325 // MARK: Equatable
326326
327- public static func == ( lhs: CustomSchemaMappingProvider , rhs: CustomSchemaMappingProvider ) -> Bool {
327+ public static func == ( lhs: CustomSchemaMappingProvider , rhs: CustomSchemaMappingProvider ) -> Bool {
328328
329329 return lhs. sourceVersion == rhs. sourceVersion
330330 && lhs. destinationVersion == rhs. destinationVersion
@@ -333,9 +333,9 @@ public class CustomSchemaMappingProvider: Hashable, SchemaMappingProvider {
333333
334334
335335 // MARK: Hashable
336-
336+
337337 public func hash( into hasher: inout Hasher ) {
338-
338+
339339 hasher. combine ( self . sourceVersion)
340340 hasher. combine ( self . destinationVersion)
341341 hasher. combine ( ObjectIdentifier ( cs_dynamicType ( of: self ) ) )
@@ -422,8 +422,8 @@ public class CustomSchemaMappingProvider: Hashable, SchemaMappingProvider {
422422 entityMapping. sourceExpression = expression ( forSource: sourceEntity)
423423 entityMapping. attributeMappings = autoreleasepool { ( ) -> [ NSPropertyMapping ] in
424424
425- let sourceAttributes = sourceEntity. cs_resolvedAttributeRenamingIdentities ( )
426- let destinationAttributes = destinationEntity. cs_resolvedAttributeRenamingIdentities ( )
425+ let sourceAttributes = sourceEntity. cs_resolveAttributeNames ( )
426+ let destinationAttributes = destinationEntity. cs_resolveAttributeRenamingIdentities ( )
427427
428428 var attributeMappings : [ NSPropertyMapping ] = [ ]
429429 for (renamingIdentifier, destination) in destinationAttributes {
@@ -439,15 +439,15 @@ public class CustomSchemaMappingProvider: Hashable, SchemaMappingProvider {
439439 }
440440 entityMapping. relationshipMappings = autoreleasepool { ( ) -> [ NSPropertyMapping ] in
441441
442- let sourceRelationships = sourceEntity. cs_resolvedRelationshipRenamingIdentities ( )
443- let destinationRelationships = destinationEntity. cs_resolvedRelationshipRenamingIdentities ( )
442+ let sourceRelationships = sourceEntity. cs_resolveRelationshipNames ( )
443+ let destinationRelationships = destinationEntity. cs_resolveRelationshipRenamingIdentities ( )
444444 var relationshipMappings : [ NSPropertyMapping ] = [ ]
445445 for (renamingIdentifier, destination) in destinationRelationships {
446446
447447 let sourceRelationship = sourceRelationships [ renamingIdentifier] !. relationship
448448 let destinationRelationship = destination. relationship
449449 let sourceRelationshipName = sourceRelationship. name
450-
450+
451451 let propertyMapping = NSPropertyMapping ( )
452452 propertyMapping. name = destinationRelationship. name
453453 propertyMapping. valueExpression = NSExpression ( format: " FUNCTION($ \( NSMigrationManagerKey) , \" destinationInstancesForSourceRelationshipNamed:sourceInstances: \" , \" \( sourceRelationshipName) \" , FUNCTION($ \( NSMigrationSourceObjectKey) , \" \( #selector( NSManagedObject . value ( forKey: ) ) ) \" , \" \( sourceRelationshipName) \" )) " )
@@ -476,12 +476,12 @@ public class CustomSchemaMappingProvider: Hashable, SchemaMappingProvider {
476476 ]
477477 autoreleasepool {
478478
479- let sourceAttributes = sourceEntity. cs_resolvedAttributeRenamingIdentities ( )
480- let destinationAttributes = destinationEntity. cs_resolvedAttributeRenamingIdentities ( )
479+ let sourceAttributes = sourceEntity. cs_resolveAttributeNames ( )
480+ let destinationAttributes = destinationEntity. cs_resolveAttributeRenamingIdentities ( )
481481
482482 let transformedRenamingIdentifiers = Set ( destinationAttributes. keys)
483483 . intersection ( sourceAttributes. keys)
484-
484+
485485 var sourceAttributesByDestinationKey : [ KeyPathString : NSAttributeDescription ] = [ : ]
486486 for renamingIdentifier in transformedRenamingIdentifiers {
487487
@@ -493,19 +493,19 @@ public class CustomSchemaMappingProvider: Hashable, SchemaMappingProvider {
493493 }
494494 entityMapping. relationshipMappings = autoreleasepool { ( ) -> [ NSPropertyMapping ] in
495495
496- let sourceRelationships = sourceEntity. cs_resolvedRelationshipRenamingIdentities ( )
497- let destinationRelationships = destinationEntity. cs_resolvedRelationshipRenamingIdentities ( )
496+ let sourceRelationships = sourceEntity. cs_resolveRelationshipNames ( )
497+ let destinationRelationships = destinationEntity. cs_resolveRelationshipRenamingIdentities ( )
498498 let transformedRenamingIdentifiers = Set ( destinationRelationships. keys)
499499 . intersection ( sourceRelationships. keys)
500-
500+
501501 var relationshipMappings : [ NSPropertyMapping ] = [ ]
502502 for renamingIdentifier in transformedRenamingIdentifiers {
503-
503+
504504 let sourceRelationship = sourceRelationships [ renamingIdentifier] !. relationship
505505 let destinationRelationship = destinationRelationships [ renamingIdentifier] !. relationship
506506 let sourceRelationshipName = sourceRelationship. name
507507 let destinationRelationshipName = destinationRelationship. name
508-
508+
509509 let propertyMapping = NSPropertyMapping ( )
510510 propertyMapping. name = destinationRelationshipName
511511 propertyMapping. valueExpression = NSExpression ( format: " FUNCTION($ \( NSMigrationManagerKey) , \" destinationInstancesForSourceRelationshipNamed:sourceInstances: \" , \" \( sourceRelationshipName) \" , FUNCTION($ \( NSMigrationSourceObjectKey) , \" \( #selector( NSManagedObject . value ( forKey: ) ) ) \" , \" \( sourceRelationshipName) \" )) " )
@@ -593,9 +593,9 @@ public class CustomSchemaMappingProvider: Hashable, SchemaMappingProvider {
593593 var allMappedSourceKeys : [ KeyPathString : KeyPathString ] = [ : ]
594594 var allMappedDestinationKeys : [ KeyPathString : KeyPathString ] = [ : ]
595595
596- let sourceRenamingIdentifiers = sourceModel. cs_resolvedRenamingIdentities ( )
596+ let sourceRenamingIdentifiers = sourceModel. cs_resolveNames ( )
597597 let sourceEntityNames = sourceModel. entitiesByName
598- let destinationRenamingIdentifiers = destinationModel. cs_resolvedRenamingIdentities ( )
598+ let destinationRenamingIdentifiers = destinationModel. cs_resolveRenamingIdentities ( )
599599 let destinationEntityNames = destinationModel. entitiesByName
600600
601601 let removedRenamingIdentifiers = Set ( sourceRenamingIdentifiers. keys)
@@ -610,7 +610,7 @@ public class CustomSchemaMappingProvider: Hashable, SchemaMappingProvider {
610610 for mapping in self . entityMappings {
611611
612612 switch mapping {
613-
613+
614614 case . deleteEntity( let sourceEntity) :
615615 CoreStore . assert (
616616 sourceEntityNames [ sourceEntity] != nil ,
@@ -622,7 +622,7 @@ public class CustomSchemaMappingProvider: Hashable, SchemaMappingProvider {
622622 )
623623 deleteMappings. insert ( mapping)
624624 allMappedSourceKeys [ sourceEntity] = " "
625-
625+
626626 case . insertEntity( let destinationEntity) :
627627 CoreStore . assert (
628628 destinationEntityNames [ destinationEntity] != nil ,
@@ -634,7 +634,7 @@ public class CustomSchemaMappingProvider: Hashable, SchemaMappingProvider {
634634 )
635635 insertMappings. insert ( mapping)
636636 allMappedDestinationKeys [ destinationEntity] = " "
637-
637+
638638 case . transformEntity( let sourceEntity, let destinationEntity, _) :
639639 CoreStore . assert (
640640 sourceEntityNames [ sourceEntity] != nil ,
@@ -655,7 +655,7 @@ public class CustomSchemaMappingProvider: Hashable, SchemaMappingProvider {
655655 transformMappings. insert ( mapping)
656656 allMappedSourceKeys [ sourceEntity] = destinationEntity
657657 allMappedDestinationKeys [ destinationEntity] = sourceEntity
658-
658+
659659 case . copyEntity( let sourceEntity, let destinationEntity) :
660660 CoreStore . assert (
661661 sourceEntityNames [ sourceEntity] != nil ,
@@ -689,7 +689,7 @@ public class CustomSchemaMappingProvider: Hashable, SchemaMappingProvider {
689689 let sourceEntityName = sourceEntity. name!
690690 let destinationEntityName = destinationEntity. name!
691691 switch ( allMappedSourceKeys [ sourceEntityName] , allMappedDestinationKeys [ destinationEntityName] ) {
692-
692+
693693 case ( nil , nil ) :
694694 if sourceEntity. versionHash == destinationEntity. versionHash {
695695
@@ -699,8 +699,7 @@ public class CustomSchemaMappingProvider: Hashable, SchemaMappingProvider {
699699 destinationEntity: destinationEntityName
700700 )
701701 )
702- }
703- else {
702+ } else {
704703
705704 transformMappings. insert (
706705 . transformEntity(
@@ -712,15 +711,15 @@ public class CustomSchemaMappingProvider: Hashable, SchemaMappingProvider {
712711 }
713712 allMappedSourceKeys [ sourceEntityName] = destinationEntityName
714713 allMappedDestinationKeys [ destinationEntityName] = sourceEntityName
715-
714+
716715 case ( " " ? , nil ) :
717716 insertMappings. insert ( . insertEntity( destinationEntity: destinationEntityName) )
718717 allMappedDestinationKeys [ destinationEntityName] = " "
719-
718+
720719 case ( nil , " " ? ) :
721720 deleteMappings. insert ( . deleteEntity( sourceEntity: sourceEntityName) )
722721 allMappedSourceKeys [ sourceEntityName] = " "
723-
722+
724723 default :
725724 continue
726725 }
@@ -730,11 +729,11 @@ public class CustomSchemaMappingProvider: Hashable, SchemaMappingProvider {
730729 let sourceEntity = sourceRenamingIdentifiers [ renamingIdentifier] !. entity
731730 let sourceEntityName = sourceEntity. name!
732731 switch allMappedSourceKeys [ sourceEntityName] {
733-
732+
734733 case nil :
735734 deleteMappings. insert ( . deleteEntity( sourceEntity: sourceEntityName) )
736735 allMappedSourceKeys [ sourceEntityName] = " "
737-
736+
738737 default :
739738 continue
740739 }
@@ -744,11 +743,11 @@ public class CustomSchemaMappingProvider: Hashable, SchemaMappingProvider {
744743 let destinationEntity = destinationRenamingIdentifiers [ renamingIdentifier] !. entity
745744 let destinationEntityName = destinationEntity. name!
746745 switch allMappedDestinationKeys [ destinationEntityName] {
747-
746+
748747 case nil :
749748 insertMappings. insert ( . insertEntity( destinationEntity: destinationEntityName) )
750749 allMappedDestinationKeys [ destinationEntityName] = " "
751-
750+
752751 default :
753752 continue
754753 }
0 commit comments