mirror of
https://github.com/JohnEstropia/CoreStore.git
synced 2026-01-15 13:43:43 +01:00
force dynamic dispatch on generic types
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -52,13 +52,13 @@ public /*abstract*/ class BaseDataTransaction {
|
||||
*/
|
||||
public func create<T: NSManagedObject>(_ into: Into<T>) -> 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
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user