Merge branch 'develop' into throwables

This commit is contained in:
John Estropia
2019-01-16 17:03:49 +09:00
4 changed files with 93 additions and 85 deletions

View File

@@ -1,5 +1,5 @@
language: objective-c language: objective-c
osx_image: xcode9 osx_image: xcode10
sudo: false sudo: false
git: git:
submodules: false submodules: false
@@ -10,17 +10,17 @@ env:
- LC_CTYPE=en_US.UTF-8 - LC_CTYPE=en_US.UTF-8
- LANG=en_US.UTF-8 - LANG=en_US.UTF-8
matrix: matrix:
- DESTINATION="OS=11.0,name=iPhone 8" SCHEME="CoreStore iOS" SDK=iphonesimulator11.0 RUN_TESTS="YES" POD_LINT="NO" - DESTINATION="arch=x86_64" SCHEME="CoreStore OSX" SDK=macosx10.14 RUN_TESTS="YES" POD_LINT="NO"
- DESTINATION="OS=10.3,name=iPhone 7" SCHEME="CoreStore iOS" SDK=iphonesimulator11.0 RUN_TESTS="YES" POD_LINT="NO" - DESTINATION="OS=12.0,name=iPhone XS" SCHEME="CoreStore iOS" SDK=iphonesimulator12.0 RUN_TESTS="YES" POD_LINT="NO"
- DESTINATION="OS=10.1,name=iPhone 7" SCHEME="CoreStore iOS" SDK=iphonesimulator11.0 RUN_TESTS="YES" POD_LINT="NO" - DESTINATION="OS=11.0.1,name=iPhone 8" SCHEME="CoreStore iOS" SDK=iphonesimulator12.0 RUN_TESTS="YES" POD_LINT="NO"
- DESTINATION="OS=9.0,name=iPhone 6 Plus" SCHEME="CoreStore iOS" SDK=iphonesimulator11.0 RUN_TESTS="YES" POD_LINT="NO" - DESTINATION="OS=10.3.1,name=iPhone 7" SCHEME="CoreStore iOS" SDK=iphonesimulator12.0 RUN_TESTS="YES" POD_LINT="NO"
- DESTINATION="arch=x86_64" SCHEME="CoreStore OSX" SDK=macosx10.13 RUN_TESTS="YES" POD_LINT="NO" - DESTINATION="OS=10.1,name=iPhone 7" SCHEME="CoreStore iOS" SDK=iphonesimulator12.0 RUN_TESTS="YES" POD_LINT="NO"
- DESTINATION="OS=4.0,name=Apple Watch - 42mm" SCHEME="CoreStore watchOS" SDK=watchsimulator4.0 RUN_TESTS="NO" POD_LINT="NO" - DESTINATION="OS=4.0,name=Apple Watch - 42mm" SCHEME="CoreStore watchOS" SDK=watchsimulator5.0 RUN_TESTS="NO" POD_LINT="NO"
- DESTINATION="OS=3.2,name=Apple Watch - 42mm" SCHEME="CoreStore watchOS" SDK=watchsimulator4.0 RUN_TESTS="NO" POD_LINT="NO" - DESTINATION="OS=3.2,name=Apple Watch - 42mm" SCHEME="CoreStore watchOS" SDK=watchsimulator5.0 RUN_TESTS="NO" POD_LINT="NO"
- DESTINATION="OS=2.2,name=Apple Watch - 42mm" SCHEME="CoreStore watchOS" SDK=watchsimulator4.0 RUN_TESTS="NO" POD_LINT="NO" - DESTINATION="OS=2.2,name=Apple Watch - 42mm" SCHEME="CoreStore watchOS" SDK=watchsimulator5.0 RUN_TESTS="NO" POD_LINT="NO"
- DESTINATION="OS=11.0,name=Apple TV 1080p" SCHEME="CoreStore tvOS" SDK=appletvsimulator11.0 RUN_TESTS="YES" POD_LINT="NO" - DESTINATION="OS=12.0,name=Apple TV 4K" SCHEME="CoreStore tvOS" SDK=appletvsimulator12.0 RUN_TESTS="YES" POD_LINT="NO"
- DESTINATION="OS=10.2,name=Apple TV 1080p" SCHEME="CoreStore tvOS" SDK=appletvsimulator11.0 RUN_TESTS="YES" POD_LINT="NO" - DESTINATION="OS=11.0,name=Apple TV 4K (at 1080p)" SCHEME="CoreStore tvOS" SDK=appletvsimulator12.0 RUN_TESTS="YES" POD_LINT="NO"
- DESTINATION="OS=9.2,name=Apple TV 1080p" SCHEME="CoreStore tvOS" SDK=appletvsimulator11.0 RUN_TESTS="YES" POD_LINT="NO" - DESTINATION="OS=10.2,name=Apple TV 1080p" SCHEME="CoreStore tvOS" SDK=appletvsimulator12.0 RUN_TESTS="YES" POD_LINT="NO"
before_install: before_install:
- gem install cocoapods --no-rdoc --no-ri --no-document --quiet - gem install cocoapods --no-rdoc --no-ri --no-document --quiet
- gem install xcpretty --no-rdoc --no-ri --no-document --quiet - gem install xcpretty --no-rdoc --no-ri --no-document --quiet
@@ -39,8 +39,8 @@ script:
xcodebuild -workspace CoreStore.xcworkspace -scheme "$SCHEME" -sdk "$SDK" -destination "$DESTINATION" -configuration Debug ONLY_ACTIVE_ARCH=NO clean test | xcpretty -c; xcodebuild -workspace CoreStore.xcworkspace -scheme "$SCHEME" -sdk "$SDK" -destination "$DESTINATION" -configuration Debug ONLY_ACTIVE_ARCH=NO clean test | xcpretty -c;
xcodebuild -workspace CoreStore.xcworkspace -scheme "$SCHEME" -sdk "$SDK" -destination "$DESTINATION" -configuration Release ONLY_ACTIVE_ARCH=NO clean test | xcpretty -c; xcodebuild -workspace CoreStore.xcworkspace -scheme "$SCHEME" -sdk "$SDK" -destination "$DESTINATION" -configuration Release ONLY_ACTIVE_ARCH=NO clean test | xcpretty -c;
fi fi
- xcodebuild -workspace "CoreStore.xcworkspace" -scheme "CoreStoreDemo" -sdk "iphonesimulator11.0" -destination "OS=11.0,name=iPhone 8" -configuration Debug ONLY_ACTIVE_ARCH=NO build | xcpretty -c; - xcodebuild -workspace "CoreStore.xcworkspace" -scheme "CoreStoreDemo" -sdk "iphonesimulator12.0" -destination "OS=11.0.1,name=iPhone 8" -configuration Debug ONLY_ACTIVE_ARCH=NO build | xcpretty -c;
- xcodebuild -workspace "CoreStore.xcworkspace" -scheme "CoreStoreDemo" -sdk "iphonesimulator11.0" -destination "OS=11.0,name=iPhone 8" -configuration Release ONLY_ACTIVE_ARCH=NO build | xcpretty -c; - xcodebuild -workspace "CoreStore.xcworkspace" -scheme "CoreStoreDemo" -sdk "iphonesimulator12.0" -destination "OS=11.0.1,name=iPhone 8" -configuration Release ONLY_ACTIVE_ARCH=NO build | xcpretty -c;
- if [ $POD_LINT == "YES" ]; then - if [ $POD_LINT == "YES" ]; then
pod lib lint --quick; pod lib lint --quick;
fi fi

View File

@@ -121,24 +121,24 @@ public class CustomSchemaMappingProvider: Hashable, SchemaMappingProvider {
// MARK: Equatable // MARK: Equatable
public static func == (lhs: CustomMapping, rhs: CustomMapping) -> Bool { public static func ==(lhs: CustomMapping, rhs: CustomMapping) -> Bool {
switch (lhs, rhs) { switch (lhs, rhs) {
case (.deleteEntity(let sourceEntity1), .deleteEntity(let sourceEntity2)): case (.deleteEntity(let sourceEntity1), .deleteEntity(let sourceEntity2)):
return sourceEntity1 == sourceEntity2 return sourceEntity1 == sourceEntity2
case (.insertEntity(let destinationEntity1), .insertEntity(let destinationEntity2)): case (.insertEntity(let destinationEntity1), .insertEntity(let destinationEntity2)):
return destinationEntity1 == destinationEntity2 return destinationEntity1 == destinationEntity2
case (.copyEntity(let sourceEntity1, let destinationEntity1), .copyEntity(let sourceEntity2, let destinationEntity2)): case (.copyEntity(let sourceEntity1, let destinationEntity1), .copyEntity(let sourceEntity2, let destinationEntity2)):
return sourceEntity1 == sourceEntity2 return sourceEntity1 == sourceEntity2
&& destinationEntity1 == destinationEntity2 && destinationEntity1 == destinationEntity2
case (.transformEntity(let sourceEntity1, let destinationEntity1, _), .transformEntity(let sourceEntity2, let destinationEntity2, _)): case (.transformEntity(let sourceEntity1, let destinationEntity1, _), .transformEntity(let sourceEntity2, let destinationEntity2, _)):
return sourceEntity1 == sourceEntity2 return sourceEntity1 == sourceEntity2
&& destinationEntity1 == destinationEntity2 && destinationEntity1 == destinationEntity2
default: default:
return false return false
} }
@@ -146,24 +146,24 @@ public class CustomSchemaMappingProvider: Hashable, SchemaMappingProvider {
// MARK: Hashable // MARK: Hashable
public func hash(into hasher: inout Hasher) { public func hash(into hasher: inout Hasher) {
switch self { switch self {
case .deleteEntity(let sourceEntity): case .deleteEntity(let sourceEntity):
hasher.combine(0) hasher.combine(0)
hasher.combine(sourceEntity) hasher.combine(sourceEntity)
case .insertEntity(let destinationEntity): case .insertEntity(let destinationEntity):
hasher.combine(1) hasher.combine(1)
hasher.combine(destinationEntity) hasher.combine(destinationEntity)
case .copyEntity(let sourceEntity, let destinationEntity): case .copyEntity(let sourceEntity, let destinationEntity):
hasher.combine(2) hasher.combine(2)
hasher.combine(sourceEntity) hasher.combine(sourceEntity)
hasher.combine(destinationEntity) hasher.combine(destinationEntity)
case .transformEntity(let sourceEntity, let destinationEntity, _): case .transformEntity(let sourceEntity, let destinationEntity, _):
hasher.combine(3) hasher.combine(3)
hasher.combine(sourceEntity) hasher.combine(sourceEntity)
@@ -177,12 +177,12 @@ public class CustomSchemaMappingProvider: Hashable, SchemaMappingProvider {
fileprivate var entityMappingSourceEntity: EntityName? { fileprivate var entityMappingSourceEntity: EntityName? {
switch self { switch self {
case .deleteEntity(let sourceEntity), case .deleteEntity(let sourceEntity),
.copyEntity(let sourceEntity, _), .copyEntity(let sourceEntity, _),
.transformEntity(let sourceEntity, _, _): .transformEntity(let sourceEntity, _, _):
return sourceEntity return sourceEntity
case .insertEntity: case .insertEntity:
return nil return nil
} }
@@ -191,12 +191,12 @@ public class CustomSchemaMappingProvider: Hashable, SchemaMappingProvider {
fileprivate var entityMappingDestinationEntity: EntityName? { fileprivate var entityMappingDestinationEntity: EntityName? {
switch self { switch self {
case .insertEntity(let destinationEntity), case .insertEntity(let destinationEntity),
.copyEntity(_, let destinationEntity), .copyEntity(_, let destinationEntity),
.transformEntity(_, let destinationEntity, _): .transformEntity(_, let destinationEntity, _):
return destinationEntity return destinationEntity
case .deleteEntity: case .deleteEntity:
return nil return nil
} }
@@ -324,7 +324,7 @@ public class CustomSchemaMappingProvider: Hashable, SchemaMappingProvider {
// MARK: Equatable // MARK: Equatable
public static func == (lhs: CustomSchemaMappingProvider, rhs: CustomSchemaMappingProvider) -> Bool { public static func ==(lhs: CustomSchemaMappingProvider, rhs: CustomSchemaMappingProvider) -> Bool {
return lhs.sourceVersion == rhs.sourceVersion return lhs.sourceVersion == rhs.sourceVersion
&& lhs.destinationVersion == rhs.destinationVersion && lhs.destinationVersion == rhs.destinationVersion
@@ -333,9 +333,9 @@ public class CustomSchemaMappingProvider: Hashable, SchemaMappingProvider {
// MARK: Hashable // MARK: Hashable
public func hash(into hasher: inout Hasher) { public func hash(into hasher: inout Hasher) {
hasher.combine(self.sourceVersion) hasher.combine(self.sourceVersion)
hasher.combine(self.destinationVersion) hasher.combine(self.destinationVersion)
hasher.combine(ObjectIdentifier(cs_dynamicType(of: self))) hasher.combine(ObjectIdentifier(cs_dynamicType(of: self)))
@@ -422,8 +422,8 @@ public class CustomSchemaMappingProvider: Hashable, SchemaMappingProvider {
entityMapping.sourceExpression = expression(forSource: sourceEntity) entityMapping.sourceExpression = expression(forSource: sourceEntity)
entityMapping.attributeMappings = autoreleasepool { () -> [NSPropertyMapping] in entityMapping.attributeMappings = autoreleasepool { () -> [NSPropertyMapping] in
let sourceAttributes = sourceEntity.cs_resolvedAttributeRenamingIdentities() let sourceAttributes = sourceEntity.cs_resolveAttributeNames()
let destinationAttributes = destinationEntity.cs_resolvedAttributeRenamingIdentities() let destinationAttributes = destinationEntity.cs_resolveAttributeRenamingIdentities()
var attributeMappings: [NSPropertyMapping] = [] var attributeMappings: [NSPropertyMapping] = []
for (renamingIdentifier, destination) in destinationAttributes { for (renamingIdentifier, destination) in destinationAttributes {
@@ -439,15 +439,15 @@ public class CustomSchemaMappingProvider: Hashable, SchemaMappingProvider {
} }
entityMapping.relationshipMappings = autoreleasepool { () -> [NSPropertyMapping] in entityMapping.relationshipMappings = autoreleasepool { () -> [NSPropertyMapping] in
let sourceRelationships = sourceEntity.cs_resolvedRelationshipRenamingIdentities() let sourceRelationships = sourceEntity.cs_resolveRelationshipNames()
let destinationRelationships = destinationEntity.cs_resolvedRelationshipRenamingIdentities() let destinationRelationships = destinationEntity.cs_resolveRelationshipRenamingIdentities()
var relationshipMappings: [NSPropertyMapping] = [] var relationshipMappings: [NSPropertyMapping] = []
for (renamingIdentifier, destination) in destinationRelationships { for (renamingIdentifier, destination) in destinationRelationships {
let sourceRelationship = sourceRelationships[renamingIdentifier]!.relationship let sourceRelationship = sourceRelationships[renamingIdentifier]!.relationship
let destinationRelationship = destination.relationship let destinationRelationship = destination.relationship
let sourceRelationshipName = sourceRelationship.name let sourceRelationshipName = sourceRelationship.name
let propertyMapping = NSPropertyMapping() let propertyMapping = NSPropertyMapping()
propertyMapping.name = destinationRelationship.name propertyMapping.name = destinationRelationship.name
propertyMapping.valueExpression = NSExpression(format: "FUNCTION($\(NSMigrationManagerKey), \"destinationInstancesForSourceRelationshipNamed:sourceInstances:\", \"\(sourceRelationshipName)\", FUNCTION($\(NSMigrationSourceObjectKey), \"\(#selector(NSManagedObject.value(forKey:)))\", \"\(sourceRelationshipName)\"))") 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 {
] ]
autoreleasepool { autoreleasepool {
let sourceAttributes = sourceEntity.cs_resolvedAttributeRenamingIdentities() let sourceAttributes = sourceEntity.cs_resolveAttributeNames()
let destinationAttributes = destinationEntity.cs_resolvedAttributeRenamingIdentities() let destinationAttributes = destinationEntity.cs_resolveAttributeRenamingIdentities()
let transformedRenamingIdentifiers = Set(destinationAttributes.keys) let transformedRenamingIdentifiers = Set(destinationAttributes.keys)
.intersection(sourceAttributes.keys) .intersection(sourceAttributes.keys)
var sourceAttributesByDestinationKey: [KeyPathString: NSAttributeDescription] = [:] var sourceAttributesByDestinationKey: [KeyPathString: NSAttributeDescription] = [:]
for renamingIdentifier in transformedRenamingIdentifiers { for renamingIdentifier in transformedRenamingIdentifiers {
@@ -493,19 +493,19 @@ public class CustomSchemaMappingProvider: Hashable, SchemaMappingProvider {
} }
entityMapping.relationshipMappings = autoreleasepool { () -> [NSPropertyMapping] in entityMapping.relationshipMappings = autoreleasepool { () -> [NSPropertyMapping] in
let sourceRelationships = sourceEntity.cs_resolvedRelationshipRenamingIdentities() let sourceRelationships = sourceEntity.cs_resolveRelationshipNames()
let destinationRelationships = destinationEntity.cs_resolvedRelationshipRenamingIdentities() let destinationRelationships = destinationEntity.cs_resolveRelationshipRenamingIdentities()
let transformedRenamingIdentifiers = Set(destinationRelationships.keys) let transformedRenamingIdentifiers = Set(destinationRelationships.keys)
.intersection(sourceRelationships.keys) .intersection(sourceRelationships.keys)
var relationshipMappings: [NSPropertyMapping] = [] var relationshipMappings: [NSPropertyMapping] = []
for renamingIdentifier in transformedRenamingIdentifiers { for renamingIdentifier in transformedRenamingIdentifiers {
let sourceRelationship = sourceRelationships[renamingIdentifier]!.relationship let sourceRelationship = sourceRelationships[renamingIdentifier]!.relationship
let destinationRelationship = destinationRelationships[renamingIdentifier]!.relationship let destinationRelationship = destinationRelationships[renamingIdentifier]!.relationship
let sourceRelationshipName = sourceRelationship.name let sourceRelationshipName = sourceRelationship.name
let destinationRelationshipName = destinationRelationship.name let destinationRelationshipName = destinationRelationship.name
let propertyMapping = NSPropertyMapping() let propertyMapping = NSPropertyMapping()
propertyMapping.name = destinationRelationshipName propertyMapping.name = destinationRelationshipName
propertyMapping.valueExpression = NSExpression(format: "FUNCTION($\(NSMigrationManagerKey), \"destinationInstancesForSourceRelationshipNamed:sourceInstances:\", \"\(sourceRelationshipName)\", FUNCTION($\(NSMigrationSourceObjectKey), \"\(#selector(NSManagedObject.value(forKey:)))\", \"\(sourceRelationshipName)\"))") 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 {
var allMappedSourceKeys: [KeyPathString: KeyPathString] = [:] var allMappedSourceKeys: [KeyPathString: KeyPathString] = [:]
var allMappedDestinationKeys: [KeyPathString: KeyPathString] = [:] var allMappedDestinationKeys: [KeyPathString: KeyPathString] = [:]
let sourceRenamingIdentifiers = sourceModel.cs_resolvedRenamingIdentities() let sourceRenamingIdentifiers = sourceModel.cs_resolveNames()
let sourceEntityNames = sourceModel.entitiesByName let sourceEntityNames = sourceModel.entitiesByName
let destinationRenamingIdentifiers = destinationModel.cs_resolvedRenamingIdentities() let destinationRenamingIdentifiers = destinationModel.cs_resolveRenamingIdentities()
let destinationEntityNames = destinationModel.entitiesByName let destinationEntityNames = destinationModel.entitiesByName
let removedRenamingIdentifiers = Set(sourceRenamingIdentifiers.keys) let removedRenamingIdentifiers = Set(sourceRenamingIdentifiers.keys)
@@ -610,7 +610,7 @@ public class CustomSchemaMappingProvider: Hashable, SchemaMappingProvider {
for mapping in self.entityMappings { for mapping in self.entityMappings {
switch mapping { switch mapping {
case .deleteEntity(let sourceEntity): case .deleteEntity(let sourceEntity):
CoreStore.assert( CoreStore.assert(
sourceEntityNames[sourceEntity] != nil, sourceEntityNames[sourceEntity] != nil,
@@ -622,7 +622,7 @@ public class CustomSchemaMappingProvider: Hashable, SchemaMappingProvider {
) )
deleteMappings.insert(mapping) deleteMappings.insert(mapping)
allMappedSourceKeys[sourceEntity] = "" allMappedSourceKeys[sourceEntity] = ""
case .insertEntity(let destinationEntity): case .insertEntity(let destinationEntity):
CoreStore.assert( CoreStore.assert(
destinationEntityNames[destinationEntity] != nil, destinationEntityNames[destinationEntity] != nil,
@@ -634,7 +634,7 @@ public class CustomSchemaMappingProvider: Hashable, SchemaMappingProvider {
) )
insertMappings.insert(mapping) insertMappings.insert(mapping)
allMappedDestinationKeys[destinationEntity] = "" allMappedDestinationKeys[destinationEntity] = ""
case .transformEntity(let sourceEntity, let destinationEntity, _): case .transformEntity(let sourceEntity, let destinationEntity, _):
CoreStore.assert( CoreStore.assert(
sourceEntityNames[sourceEntity] != nil, sourceEntityNames[sourceEntity] != nil,
@@ -655,7 +655,7 @@ public class CustomSchemaMappingProvider: Hashable, SchemaMappingProvider {
transformMappings.insert(mapping) transformMappings.insert(mapping)
allMappedSourceKeys[sourceEntity] = destinationEntity allMappedSourceKeys[sourceEntity] = destinationEntity
allMappedDestinationKeys[destinationEntity] = sourceEntity allMappedDestinationKeys[destinationEntity] = sourceEntity
case .copyEntity(let sourceEntity, let destinationEntity): case .copyEntity(let sourceEntity, let destinationEntity):
CoreStore.assert( CoreStore.assert(
sourceEntityNames[sourceEntity] != nil, sourceEntityNames[sourceEntity] != nil,
@@ -689,7 +689,7 @@ public class CustomSchemaMappingProvider: Hashable, SchemaMappingProvider {
let sourceEntityName = sourceEntity.name! let sourceEntityName = sourceEntity.name!
let destinationEntityName = destinationEntity.name! let destinationEntityName = destinationEntity.name!
switch (allMappedSourceKeys[sourceEntityName], allMappedDestinationKeys[destinationEntityName]) { switch (allMappedSourceKeys[sourceEntityName], allMappedDestinationKeys[destinationEntityName]) {
case (nil, nil): case (nil, nil):
if sourceEntity.versionHash == destinationEntity.versionHash { if sourceEntity.versionHash == destinationEntity.versionHash {
@@ -699,8 +699,7 @@ public class CustomSchemaMappingProvider: Hashable, SchemaMappingProvider {
destinationEntity: destinationEntityName destinationEntity: destinationEntityName
) )
) )
} } else {
else {
transformMappings.insert( transformMappings.insert(
.transformEntity( .transformEntity(
@@ -712,15 +711,15 @@ public class CustomSchemaMappingProvider: Hashable, SchemaMappingProvider {
} }
allMappedSourceKeys[sourceEntityName] = destinationEntityName allMappedSourceKeys[sourceEntityName] = destinationEntityName
allMappedDestinationKeys[destinationEntityName] = sourceEntityName allMappedDestinationKeys[destinationEntityName] = sourceEntityName
case (""?, nil): case (""?, nil):
insertMappings.insert(.insertEntity(destinationEntity: destinationEntityName)) insertMappings.insert(.insertEntity(destinationEntity: destinationEntityName))
allMappedDestinationKeys[destinationEntityName] = "" allMappedDestinationKeys[destinationEntityName] = ""
case (nil, ""?): case (nil, ""?):
deleteMappings.insert(.deleteEntity(sourceEntity: sourceEntityName)) deleteMappings.insert(.deleteEntity(sourceEntity: sourceEntityName))
allMappedSourceKeys[sourceEntityName] = "" allMappedSourceKeys[sourceEntityName] = ""
default: default:
continue continue
} }
@@ -730,11 +729,11 @@ public class CustomSchemaMappingProvider: Hashable, SchemaMappingProvider {
let sourceEntity = sourceRenamingIdentifiers[renamingIdentifier]!.entity let sourceEntity = sourceRenamingIdentifiers[renamingIdentifier]!.entity
let sourceEntityName = sourceEntity.name! let sourceEntityName = sourceEntity.name!
switch allMappedSourceKeys[sourceEntityName] { switch allMappedSourceKeys[sourceEntityName] {
case nil: case nil:
deleteMappings.insert(.deleteEntity(sourceEntity: sourceEntityName)) deleteMappings.insert(.deleteEntity(sourceEntity: sourceEntityName))
allMappedSourceKeys[sourceEntityName] = "" allMappedSourceKeys[sourceEntityName] = ""
default: default:
continue continue
} }
@@ -744,11 +743,11 @@ public class CustomSchemaMappingProvider: Hashable, SchemaMappingProvider {
let destinationEntity = destinationRenamingIdentifiers[renamingIdentifier]!.entity let destinationEntity = destinationRenamingIdentifiers[renamingIdentifier]!.entity
let destinationEntityName = destinationEntity.name! let destinationEntityName = destinationEntity.name!
switch allMappedDestinationKeys[destinationEntityName] { switch allMappedDestinationKeys[destinationEntityName] {
case nil: case nil:
insertMappings.insert(.insertEntity(destinationEntity: destinationEntityName)) insertMappings.insert(.insertEntity(destinationEntity: destinationEntityName))
allMappedDestinationKeys[destinationEntityName] = "" allMappedDestinationKeys[destinationEntityName] = ""
default: default:
continue continue
} }

View File

@@ -32,24 +32,30 @@ import Foundation
internal extension NSEntityDescription { internal extension NSEntityDescription {
@nonobjc @nonobjc
internal func cs_resolvedAttributeRenamingIdentities() -> [String: (attribute: NSAttributeDescription, versionHash: Data)] { internal func cs_resolveAttributeNames() -> [String: (attribute: NSAttributeDescription, versionHash: Data)] {
return self.attributesByName.reduce(into: [:], { (result, attribute: (name: String, description: NSAttributeDescription)) in
var mapping: [String: (attribute: NSAttributeDescription, versionHash: Data)] = [:] result[attribute.name] = (attribute.description, attribute.description.versionHash)
for (attributeName, attributeDescription) in self.attributesByName { })
mapping[attributeDescription.renamingIdentifier ?? attributeName] = (attributeDescription, attributeDescription.versionHash)
}
return mapping
} }
@nonobjc @nonobjc
internal func cs_resolvedRelationshipRenamingIdentities() -> [String: (relationship: NSRelationshipDescription, versionHash: Data)] { internal func cs_resolveAttributeRenamingIdentities() -> [String: (attribute: NSAttributeDescription, versionHash: Data)] {
return self.attributesByName.reduce(into: [:], { (result, attribute: (name: String, description: NSAttributeDescription)) in
var mapping: [String: (relationship: NSRelationshipDescription, versionHash: Data)] = [:] result[attribute.description.renamingIdentifier ?? attribute.name] = (attribute.description, attribute.description.versionHash)
for (relationshipName, relationshipDescription) in self.relationshipsByName { })
}
mapping[relationshipDescription.renamingIdentifier ?? relationshipName] = (relationshipDescription, relationshipDescription.versionHash)
} @nonobjc
return mapping internal func cs_resolveRelationshipNames() -> [String: (relationship: NSRelationshipDescription, versionHash: Data)] {
return self.relationshipsByName.reduce(into: [:], { (result, relationship: (name: String, description: NSRelationshipDescription)) in
result[relationship.name] = (relationship.description, relationship.description.versionHash)
})
}
@nonobjc
internal func cs_resolveRelationshipRenamingIdentities() -> [String: (relationship: NSRelationshipDescription, versionHash: Data)] {
return self.relationshipsByName.reduce(into: [:], { (result, relationship: (name: String, description: NSRelationshipDescription)) in
result[relationship.description.renamingIdentifier ?? relationship.name] = (relationship.description, relationship.description.versionHash)
})
} }
} }

View File

@@ -32,13 +32,16 @@ import Foundation
internal extension NSManagedObjectModel { internal extension NSManagedObjectModel {
@nonobjc @nonobjc
internal func cs_resolvedRenamingIdentities() -> [String: (entity: NSEntityDescription, versionHash: Data)] { internal func cs_resolveNames() -> [String: (entity: NSEntityDescription, versionHash: Data)] {
return self.entitiesByName.reduce(into: [:], { (result, entity: (name: String, description: NSEntityDescription)) in
var mapping: [String: (entity: NSEntityDescription, versionHash: Data)] = [:] result[entity.name] = (entity.description, entity.description.versionHash)
for (entityName, entityDescription) in self.entitiesByName { })
}
mapping[entityDescription.renamingIdentifier ?? entityName] = (entityDescription, entityDescription.versionHash)
} @nonobjc
return mapping internal func cs_resolveRenamingIdentities() -> [String: (entity: NSEntityDescription, versionHash: Data)] {
return self.entitiesByName.reduce(into: [:], { (result, entity: (name: String, description: NSEntityDescription)) in
result[entity.description.renamingIdentifier ?? entity.name] = (entity.description, entity.description.versionHash)
})
} }
} }