mirror of
https://github.com/JohnEstropia/CoreStore.git
synced 2026-07-06 21:05:07 +02:00
Merge branch 'master' into prototype/Swift_3_2
This commit is contained in:
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
Pod::Spec.new do |s|
|
Pod::Spec.new do |s|
|
||||||
s.name = "CoreStore"
|
s.name = "CoreStore"
|
||||||
s.version = "4.0.2"
|
s.version = "4.0.3"
|
||||||
s.license = "MIT"
|
s.license = "MIT"
|
||||||
s.summary = "Unleashing the real power of Core Data with the elegance and safety of Swift"
|
s.summary = "Unleashing the real power of Core Data with the elegance and safety of Swift"
|
||||||
s.homepage = "https://github.com/JohnEstropia/CoreStore"
|
s.homepage = "https://github.com/JohnEstropia/CoreStore"
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
<key>CFBundlePackageType</key>
|
<key>CFBundlePackageType</key>
|
||||||
<string>APPL</string>
|
<string>APPL</string>
|
||||||
<key>CFBundleShortVersionString</key>
|
<key>CFBundleShortVersionString</key>
|
||||||
<string>4.0.2</string>
|
<string>4.0.3</string>
|
||||||
<key>CFBundleSignature</key>
|
<key>CFBundleSignature</key>
|
||||||
<string>????</string>
|
<string>????</string>
|
||||||
<key>CFBundleVersion</key>
|
<key>CFBundleVersion</key>
|
||||||
|
|||||||
@@ -352,7 +352,7 @@ public class CustomSchemaMappingProvider: Hashable, SchemaMappingProvider {
|
|||||||
)
|
)
|
||||||
func expression(forSource sourceEntity: NSEntityDescription) -> NSExpression {
|
func expression(forSource sourceEntity: NSEntityDescription) -> NSExpression {
|
||||||
|
|
||||||
return NSExpression(format: "FETCH(FUNCTION($\(NSMigrationManagerKey), \"fetchRequestForSourceEntityNamed:predicateString:\" , \"\(sourceEntity.name!)\", \"\(NSPredicate(value: true))\"), $\(NSMigrationManagerKey).\(#keyPath(NSMigrationManager.sourceContext)), \(false))")
|
return NSExpression(format: "FETCH(FUNCTION($\(NSMigrationManagerKey), \"fetchRequestForSourceEntityNamed:predicateString:\" , \"\(sourceEntity.name!)\", \"\(NSPredicate(value: true))\"), FUNCTION($\(NSMigrationManagerKey), \"\(#selector(getter: NSMigrationManager.sourceContext))\"), \(false))")
|
||||||
}
|
}
|
||||||
|
|
||||||
let sourceEntitiesByName = sourceModel.entitiesByName
|
let sourceEntitiesByName = sourceModel.entitiesByName
|
||||||
@@ -427,22 +427,25 @@ public class CustomSchemaMappingProvider: Hashable, SchemaMappingProvider {
|
|||||||
let destinationAttribute = destination.attribute
|
let destinationAttribute = destination.attribute
|
||||||
let propertyMapping = NSPropertyMapping()
|
let propertyMapping = NSPropertyMapping()
|
||||||
propertyMapping.name = destinationAttribute.name
|
propertyMapping.name = destinationAttribute.name
|
||||||
propertyMapping.valueExpression = NSExpression(format: "$\(NSMigrationSourceObjectKey).\(sourceAttribute.name)")
|
propertyMapping.valueExpression = NSExpression(format: "FUNCTION($\(NSMigrationSourceObjectKey), \"\(#selector(NSManagedObject.value(forKey:)))\", \"\(sourceAttribute.name)\")")
|
||||||
attributeMappings.append(propertyMapping)
|
attributeMappings.append(propertyMapping)
|
||||||
}
|
}
|
||||||
return attributeMappings
|
return attributeMappings
|
||||||
}
|
}
|
||||||
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 sourceRelationshipName = sourceRelationship.name
|
||||||
|
|
||||||
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), \"destinationInstancesForSourceRelationshipNamed:sourceInstances:\", \"\(sourceRelationshipName)\", FUNCTION($\(NSMigrationSourceObjectKey), \"\(#selector(NSManagedObject.value(forKey:)))\", \"\(sourceRelationshipName)\"))")
|
||||||
relationshipMappings.append(propertyMapping)
|
relationshipMappings.append(propertyMapping)
|
||||||
}
|
}
|
||||||
return relationshipMappings
|
return relationshipMappings
|
||||||
@@ -483,17 +486,24 @@ public class CustomSchemaMappingProvider: Hashable, SchemaMappingProvider {
|
|||||||
}
|
}
|
||||||
userInfo[CustomEntityMigrationPolicy.UserInfoKey.sourceAttributesByDestinationKey] = sourceAttributesByDestinationKey
|
userInfo[CustomEntityMigrationPolicy.UserInfoKey.sourceAttributesByDestinationKey] = sourceAttributesByDestinationKey
|
||||||
}
|
}
|
||||||
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] = []
|
let transformedRenamingIdentifiers = Set(destinationRelationships.keys)
|
||||||
for (_, destination) in destinationRelationships {
|
.intersection(sourceRelationships.keys)
|
||||||
|
|
||||||
|
var relationshipMappings: [NSPropertyMapping] = []
|
||||||
|
for renamingIdentifier in transformedRenamingIdentifiers {
|
||||||
|
|
||||||
|
let sourceRelationship = sourceRelationships[renamingIdentifier]!.relationship
|
||||||
|
let destinationRelationship = destinationRelationships[renamingIdentifier]!.relationship
|
||||||
|
let sourceRelationshipName = sourceRelationship.name
|
||||||
|
let destinationRelationshipName = destinationRelationship.name
|
||||||
|
|
||||||
let destinationRelationship = destination.relationship
|
|
||||||
let propertyMapping = NSPropertyMapping()
|
let propertyMapping = NSPropertyMapping()
|
||||||
propertyMapping.name = destinationRelationship.name
|
propertyMapping.name = destinationRelationshipName
|
||||||
propertyMapping.valueExpression = NSExpression(format: "FUNCTION($\(NSMigrationManagerKey), \"\(#selector(NSMigrationManager.destinationInstances(forEntityMappingName:sourceInstances:)))\" , \"\(entityMappingName)\", $\(NSMigrationSourceObjectKey))[0]")
|
propertyMapping.valueExpression = NSExpression(format: "FUNCTION($\(NSMigrationManagerKey), \"destinationInstancesForSourceRelationshipNamed:sourceInstances:\", \"\(sourceRelationshipName)\", FUNCTION($\(NSMigrationSourceObjectKey), \"\(#selector(NSManagedObject.value(forKey:)))\", \"\(sourceRelationshipName)\"))")
|
||||||
relationshipMappings.append(propertyMapping)
|
relationshipMappings.append(propertyMapping)
|
||||||
}
|
}
|
||||||
return relationshipMappings
|
return relationshipMappings
|
||||||
@@ -545,11 +555,7 @@ public class CustomSchemaMappingProvider: Hashable, SchemaMappingProvider {
|
|||||||
)
|
)
|
||||||
if let dInstance = destinationObject?.rawObject {
|
if let dInstance = destinationObject?.rawObject {
|
||||||
|
|
||||||
manager.associate(
|
manager.associate(sourceInstance: sInstance, withDestinationInstance: dInstance, for: mapping)
|
||||||
sourceInstance: sInstance,
|
|
||||||
withDestinationInstance: dInstance,
|
|
||||||
for: mapping
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -670,7 +676,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 +748,6 @@ public class CustomSchemaMappingProvider: Hashable, SchemaMappingProvider {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return (deleteMappings, insertMappings, copyMappings, transformMappings)
|
return (deleteMappings, insertMappings, copyMappings, transformMappings)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -15,7 +15,7 @@
|
|||||||
<key>CFBundlePackageType</key>
|
<key>CFBundlePackageType</key>
|
||||||
<string>FMWK</string>
|
<string>FMWK</string>
|
||||||
<key>CFBundleShortVersionString</key>
|
<key>CFBundleShortVersionString</key>
|
||||||
<string>4.0.2</string>
|
<string>4.0.3</string>
|
||||||
<key>CFBundleSignature</key>
|
<key>CFBundleSignature</key>
|
||||||
<string>????</string>
|
<string>????</string>
|
||||||
<key>CFBundleVersion</key>
|
<key>CFBundleVersion</key>
|
||||||
|
|||||||
Reference in New Issue
Block a user