WIP: Fetching unit tests

This commit is contained in:
John Rommel Estropia
2016-06-06 00:12:00 +09:00
parent 02a89accc8
commit b98805e489
13 changed files with 1842 additions and 74 deletions

View File

@@ -64,7 +64,11 @@ public /*abstract*/ class BaseDataTransaction {
let entityClass = (into.entityClass as! NSManagedObject.Type)
if into.inferStoreIfPossible {
switch context.parentStack!.persistentStoreForEntityClass(entityClass, configuration: nil, inferStoreIfPossible: true) {
switch context.parentStack!.persistentStoreForEntityClass(
entityClass,
configuration: nil,
inferStoreIfPossible: true
) {
case (let persistentStore?, _):
let object = entityClass.createInContext(context) as! T
@@ -80,13 +84,21 @@ public /*abstract*/ class BaseDataTransaction {
}
else {
switch context.parentStack!.persistentStoreForEntityClass(entityClass, configuration: into.configuration, inferStoreIfPossible: false) {
switch context.parentStack!.persistentStoreForEntityClass(
entityClass,
configuration: into.configuration
?? into.dynamicType.defaultConfigurationName,
inferStoreIfPossible: false
) {
case (let persistentStore?, _):
let object = entityClass.createInContext(context) as! T
context.assignObject(object, toPersistentStore: persistentStore)
return object
case (nil, true):
fatalError("Attempted to create an entity of type \(cs_typeName(entityClass)) with ambiguous destination persistent store, but the configuration name was not specified.")
default:
if let configuration = into.configuration {