diff --git a/Sources/Transactions/AsynchronousDataTransaction.swift b/Sources/Transactions/AsynchronousDataTransaction.swift index c9fe49d..6a0dcb4 100644 --- a/Sources/Transactions/AsynchronousDataTransaction.swift +++ b/Sources/Transactions/AsynchronousDataTransaction.swift @@ -99,7 +99,7 @@ public final class AsynchronousDataTransaction: BaseDataTransaction { CoreStore.assert( !self.isCommitted, - "Attempted to create an entity of type \(cs_typeName(T.self)) from an already committed \(cs_typeName(self))." + "Attempted to create an entity of type \(cs_typeName(into.entityClass)) from an already committed \(cs_typeName(self))." ) return super.create(into) @@ -132,7 +132,7 @@ public final class AsynchronousDataTransaction: BaseDataTransaction { CoreStore.assert( !self.isCommitted, - "Attempted to update an entity of type \(cs_typeName(T.self)) from an already committed \(cs_typeName(self))." + "Attempted to update an entity of type \(cs_typeName(into.entityClass)) from an already committed \(cs_typeName(self))." ) return super.edit(into, objectID) diff --git a/Sources/Transactions/BaseDataTransaction.swift b/Sources/Transactions/BaseDataTransaction.swift index 8688485..3acccad 100644 --- a/Sources/Transactions/BaseDataTransaction.swift +++ b/Sources/Transactions/BaseDataTransaction.swift @@ -52,13 +52,13 @@ public /*abstract*/ class BaseDataTransaction { */ public func create(_ into: Into) -> T { + let entityClass = (into.entityClass as! T.Type) CoreStore.assert( self.isRunningInAllowedQueue(), - "Attempted to create an entity of type \(cs_typeName(T.self)) outside its designated queue." + "Attempted to create an entity of type \(cs_typeName(entityClass)) outside its designated queue." ) let context = self.context - let entityClass = (into.entityClass as! NSManagedObject.Type) if into.inferStoreIfPossible { switch context.parentStack!.persistentStoreForEntityClass( @@ -68,7 +68,7 @@ public /*abstract*/ class BaseDataTransaction { ) { case (let persistentStore?, _): - let object = entityClass.createInContext(context) as! T + let object = entityClass.createInContext(context) context.assign(object, to: persistentStore) return object @@ -89,7 +89,7 @@ public /*abstract*/ class BaseDataTransaction { ) { case (let persistentStore?, _): - let object = entityClass.createInContext(context) as! T + let object = entityClass.createInContext(context) context.assign(object, to: persistentStore) return object @@ -139,12 +139,12 @@ public /*abstract*/ class BaseDataTransaction { CoreStore.assert( self.isRunningInAllowedQueue(), - "Attempted to update an entity of type \(cs_typeName(T.self)) outside its designated queue." + "Attempted to update an entity of type \(cs_typeName(into.entityClass)) outside its designated queue." ) CoreStore.assert( into.inferStoreIfPossible || (into.configuration ?? Into.defaultConfigurationName) == objectID.persistentStore?.configurationName, - "Attempted to update an entity of type \(cs_typeName(T.self)) but the specified persistent store do not match the `NSManagedObjectID`." + "Attempted to update an entity of type \(cs_typeName(into.entityClass)) but the specified persistent store do not match the `NSManagedObjectID`." ) return self.fetchExisting(objectID) as? T } diff --git a/Sources/Transactions/SynchronousDataTransaction.swift b/Sources/Transactions/SynchronousDataTransaction.swift index 6d92745..ab8deeb 100644 --- a/Sources/Transactions/SynchronousDataTransaction.swift +++ b/Sources/Transactions/SynchronousDataTransaction.swift @@ -94,7 +94,7 @@ public final class SynchronousDataTransaction: BaseDataTransaction { CoreStore.assert( !self.isCommitted, - "Attempted to create an entity of type \(cs_typeName(T.self)) from an already committed \(cs_typeName(self))." + "Attempted to create an entity of type \(cs_typeName(into.entityClass)) from an already committed \(cs_typeName(self))." ) return super.create(into) @@ -127,7 +127,7 @@ public final class SynchronousDataTransaction: BaseDataTransaction { CoreStore.assert( !self.isCommitted, - "Attempted to update an entity of type \(cs_typeName(T.self)) from an already committed \(cs_typeName(self))." + "Attempted to update an entity of type \(cs_typeName(into.entityClass)) from an already committed \(cs_typeName(self))." ) return super.edit(into, objectID)