mirror of
https://github.com/JohnEstropia/CoreStore.git
synced 2026-01-12 04:10:36 +01:00
Unsafe transaction changes not persisted to disk if save() called on context #242
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @markst on GitHub (Nov 20, 2018).
I'm using a
UnsafeDataTransactionin combination withListMonitorwhich I display results in progress prior to committing saved changes.My
ListMonitordoes not update with results unless I call:However upon attempting to persist my changes such as:
My changes are not correctly written to persisted store.
@markst commented on GitHub (Nov 20, 2018):
If I force saving on the parent context:
The changes are correctly persisted.
@JohnEstropia commented on GitHub (Nov 20, 2018):
How do you confirm that the changes are not persisted?
Do you get an error within the
commitblock?@markst commented on GitHub (Nov 20, 2018):
No error. I perform a fetch later on in the app's lifetime & no results are returned.
It appears due to
self.hasChangesguard returning early & never breaking into saving the parent:40f458a09c/Sources/NSManagedObjectContext%2BTransaction.swift (L186)@markst commented on GitHub (Nov 30, 2018):
@JohnEstropia
On further investigation it seems I should be using
flush(). #71This produces the desired effect with
commit()correctly persisting to disk.Is it all good to simply destroy the transaction if I changes should not be persisted?
@JohnEstropia commented on GitHub (Nov 30, 2018):
@markst Yes, discarding the transaction will remove all unsaved changes.