@@ -78,6 +78,7 @@ public final class ManagedObjectViewContext: ViewContext, ObservableObject {
7878 self . context = context
7979 context. automaticallyMergesChangesFromParent = true
8080 context. stalenessInterval = 0
81+ context. undoManager = nil
8182 assert ( context. concurrencyType == . mainQueueConcurrencyType)
8283 setupNotificationObservers ( )
8384 }
@@ -86,6 +87,7 @@ public final class ManagedObjectViewContext: ViewContext, ObservableObject {
8687 self . context = persistentContainer. viewContext
8788 context. automaticallyMergesChangesFromParent = true
8889 context. stalenessInterval = 0
90+ context. undoManager = nil
8991 assert ( context. concurrencyType == . mainQueueConcurrencyType)
9092 setupNotificationObservers ( )
9193 }
@@ -166,16 +168,17 @@ internal extension NSManagedObjectContext {
166168
167169 func find(
168170 _ entityName: EntityName ,
169- for id: ObjectID
171+ for id: ObjectID ,
172+ includesPropertyValues: Bool = true
170173 ) throws -> NSManagedObject ? {
171174 let fetchRequest = FetchRequest (
172175 entity: entityName,
173176 predicate: NSManagedObject . BuiltInProperty. id. rawValue == id. rawValue,
174177 fetchLimit: 1
175- ) . toFoundation ( NSManagedObjectID . self)
176- assert ( fetchRequest. resultType == . managedObjectIDResultType )
177- let objectIDs = try self . fetch ( fetchRequest )
178- return objectIDs . first . flatMap { self . object ( with : $0 ) }
178+ ) . toFoundation ( NSManagedObject . self)
179+ fetchRequest. includesPropertyValues = includesPropertyValues
180+ assert ( fetchRequest . resultType == . managedObjectResultType )
181+ return try self . fetch ( fetchRequest ) . first
179182 }
180183
181184 func insert(
@@ -184,7 +187,7 @@ internal extension NSManagedObjectContext {
184187 shouldSave: Bool = true
185188 ) throws {
186189 // find or create
187- let managedObject = try find ( value. entity, for: value. id) ?? create ( value. entity, for: value. id, in: model)
190+ let managedObject = try find ( value. entity, for: value. id, includesPropertyValues : false ) ?? create ( value. entity, for: value. id, in: model)
188191 // apply attributes
189192 for (key, value) in value. attributes {
190193 managedObject. setAttribute ( value, for: key)
0 commit comments