mirror of
https://github.com/JohnEstropia/CoreStore.git
synced 2026-04-18 23:19:45 +02:00
WIP: bugfix for CustomSchemaMappingProvider relationship migration bug
This commit is contained in:
@@ -435,14 +435,16 @@ public class CustomSchemaMappingProvider: Hashable, SchemaMappingProvider {
|
|||||||
let entityMappingName = entityMapping.name!
|
let entityMappingName = entityMapping.name!
|
||||||
entityMapping.relationshipMappings = autoreleasepool { () -> [NSPropertyMapping] in
|
entityMapping.relationshipMappings = autoreleasepool { () -> [NSPropertyMapping] in
|
||||||
|
|
||||||
|
let sourceRelationships = sourceEntity.cs_resolvedRelationshipRenamingIdentities()
|
||||||
let destinationRelationships = destinationEntity.cs_resolvedRelationshipRenamingIdentities()
|
let destinationRelationships = destinationEntity.cs_resolvedRelationshipRenamingIdentities()
|
||||||
var relationshipMappings: [NSPropertyMapping] = []
|
var relationshipMappings: [NSPropertyMapping] = []
|
||||||
for (_, destination) in destinationRelationships {
|
for (renamingIdentifier, destination) in destinationRelationships {
|
||||||
|
|
||||||
|
let sourceRelationship = sourceRelationships[renamingIdentifier]!.relationship
|
||||||
let destinationRelationship = destination.relationship
|
let destinationRelationship = destination.relationship
|
||||||
let propertyMapping = NSPropertyMapping()
|
let propertyMapping = NSPropertyMapping()
|
||||||
propertyMapping.name = destinationRelationship.name
|
propertyMapping.name = destinationRelationship.name
|
||||||
propertyMapping.valueExpression = NSExpression(format: "FUNCTION($\(NSMigrationManagerKey), \"\(#selector(NSMigrationManager.destinationInstances(forEntityMappingName:sourceInstances:)))\" , \"\(entityMappingName)\", $\(NSMigrationSourceObjectKey))[0]")
|
propertyMapping.valueExpression = NSExpression(format: "FUNCTION($\(NSMigrationManagerKey), \"\(#selector(NSMigrationManager.destinationInstances(forEntityMappingName:sourceInstances:)))\", \"\(entityMappingName)\", $\(NSMigrationSourceObjectKey).\(sourceRelationship.name))")
|
||||||
relationshipMappings.append(propertyMapping)
|
relationshipMappings.append(propertyMapping)
|
||||||
}
|
}
|
||||||
return relationshipMappings
|
return relationshipMappings
|
||||||
@@ -486,14 +488,20 @@ public class CustomSchemaMappingProvider: Hashable, SchemaMappingProvider {
|
|||||||
let entityMappingName = entityMapping.name!
|
let entityMappingName = entityMapping.name!
|
||||||
entityMapping.relationshipMappings = autoreleasepool { () -> [NSPropertyMapping] in
|
entityMapping.relationshipMappings = autoreleasepool { () -> [NSPropertyMapping] in
|
||||||
|
|
||||||
|
let sourceRelationships = sourceEntity.cs_resolvedRelationshipRenamingIdentities()
|
||||||
let destinationRelationships = destinationEntity.cs_resolvedRelationshipRenamingIdentities()
|
let destinationRelationships = destinationEntity.cs_resolvedRelationshipRenamingIdentities()
|
||||||
var relationshipMappings: [NSPropertyMapping] = []
|
|
||||||
for (_, destination) in destinationRelationships {
|
|
||||||
|
|
||||||
|
var relationshipMappings: [NSPropertyMapping] = []
|
||||||
|
for (renamingIdentifier, destination) in destinationRelationships {
|
||||||
|
|
||||||
|
guard let sourceRelationship = sourceRelationships[renamingIdentifier]?.relationship else {
|
||||||
|
|
||||||
|
continue
|
||||||
|
}
|
||||||
let destinationRelationship = destination.relationship
|
let destinationRelationship = destination.relationship
|
||||||
let propertyMapping = NSPropertyMapping()
|
let propertyMapping = NSPropertyMapping()
|
||||||
propertyMapping.name = destinationRelationship.name
|
propertyMapping.name = destinationRelationship.name
|
||||||
propertyMapping.valueExpression = NSExpression(format: "FUNCTION($\(NSMigrationManagerKey), \"\(#selector(NSMigrationManager.destinationInstances(forEntityMappingName:sourceInstances:)))\" , \"\(entityMappingName)\", $\(NSMigrationSourceObjectKey))[0]")
|
propertyMapping.valueExpression = NSExpression(format: "FUNCTION($\(NSMigrationManagerKey), \"\(#selector(NSMigrationManager.destinationInstances(forEntityMappingName:sourceInstances:)))\", \"\(entityMappingName)\", $\(NSMigrationSourceObjectKey).\(sourceRelationship.name))")
|
||||||
relationshipMappings.append(propertyMapping)
|
relationshipMappings.append(propertyMapping)
|
||||||
}
|
}
|
||||||
return relationshipMappings
|
return relationshipMappings
|
||||||
@@ -670,7 +678,7 @@ public class CustomSchemaMappingProvider: Hashable, SchemaMappingProvider {
|
|||||||
allMappedSourceKeys[sourceEntity] = destinationEntity
|
allMappedSourceKeys[sourceEntity] = destinationEntity
|
||||||
allMappedDestinationKeys[destinationEntity] = sourceEntity
|
allMappedDestinationKeys[destinationEntity] = sourceEntity
|
||||||
}
|
}
|
||||||
|
}
|
||||||
for renamingIdentifier in transformedRenamingIdentifiers {
|
for renamingIdentifier in transformedRenamingIdentifiers {
|
||||||
|
|
||||||
let sourceEntity = sourceRenamingIdentifiers[renamingIdentifier]!.entity
|
let sourceEntity = sourceRenamingIdentifiers[renamingIdentifier]!.entity
|
||||||
@@ -742,7 +750,6 @@ public class CustomSchemaMappingProvider: Hashable, SchemaMappingProvider {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return (deleteMappings, insertMappings, copyMappings, transformMappings)
|
return (deleteMappings, insertMappings, copyMappings, transformMappings)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user