mirror of
https://github.com/JohnEstropia/CoreStore.git
synced 2026-03-19 16:21:27 +01:00
Merge branch 'develop' of github.com:JohnEstropia/CoreStore into develop
This commit is contained in:
@@ -213,6 +213,25 @@ public /*abstract*/ class BaseDataTransaction {
|
||||
|
||||
|
||||
// MARK: Inspecting Pending Objects
|
||||
|
||||
/**
|
||||
Returns `true` if the object has any property values changed. This method should not be called after the `commit()` method was called.
|
||||
|
||||
- parameter entity: the `DynamicObject` instance
|
||||
- returns: `true` if the object has any property values changed.
|
||||
*/
|
||||
public func objectHasPersistentChangedValues<D: DynamicObject>(_ entity: D) -> Bool {
|
||||
|
||||
CoreStore.assert(
|
||||
self.isRunningInAllowedQueue(),
|
||||
"Attempted to access inserted objects from a \(cs_typeName(self)) outside its designated queue."
|
||||
)
|
||||
CoreStore.assert(
|
||||
!self.isCommitted,
|
||||
"Attempted to access inserted objects from an already committed \(cs_typeName(self))."
|
||||
)
|
||||
return entity.cs_toRaw().hasPersistentChangedValues
|
||||
}
|
||||
|
||||
/**
|
||||
Returns all pending `DynamicObject`s of the specified type that were inserted to the transaction. This method should not be called after the `commit()` method was called.
|
||||
|
||||
@@ -140,8 +140,16 @@ public struct From<D: DynamicObject> {
|
||||
}
|
||||
|
||||
internal func applyToFetchRequest<U>(_ fetchRequest: CoreStoreFetchRequest<U>, context: NSManagedObjectContext, applyAffectedStores: Bool = true) throws {
|
||||
|
||||
fetchRequest.entity = context.parentStack!.entityDescription(for: EntityIdentifier(self.entityClass))!
|
||||
|
||||
guard let parentStack = context.parentStack else {
|
||||
|
||||
CoreStore.log(
|
||||
.warning,
|
||||
message: "Attempted to perform a fetch but the \(cs_typeName(DataStack.self)) has already been deallocated."
|
||||
)
|
||||
throw CoreStoreError.unknown
|
||||
}
|
||||
fetchRequest.entity = parentStack.entityDescription(for: EntityIdentifier(self.entityClass))!
|
||||
guard applyAffectedStores else {
|
||||
|
||||
return
|
||||
|
||||
@@ -963,8 +963,15 @@ public final class ListMonitor<D: DynamicObject>: Hashable {
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
try! newFetchedResultsController.performFetchFromSpecifiedStores()
|
||||
do {
|
||||
|
||||
try newFetchedResultsController.performFetchFromSpecifiedStores()
|
||||
}
|
||||
catch {
|
||||
|
||||
// DataStack may have been deallocated
|
||||
return
|
||||
}
|
||||
self.fetchedResultsControllerDelegate.taskGroup.notify(queue: .main) {
|
||||
|
||||
self.fetchedResultsControllerDelegate.enabled = false
|
||||
|
||||
Reference in New Issue
Block a user