Open tosbaha opened 6 years ago
@tosbaha If I'm interpreting your error message correctly,
NSValidationErrorObject=<KargoDetailCD: 0x600000289fb0> ... NSValidationErrorKey=parent
I think the issue is that the moment this line is executed,
self.detail = NSOrderedSet(array: details)
the old KargoDetailCD
instances get their KargoDetailCD.parent
set to nil
. You probably have a "required" constraint for the KargoDetailCD.parent
relation.
Either you remove this requirement, or you delete the old details before you assign new ones. I would recommend the latter so your sqlite file don't get polluted with orphaned records.
Thanks a lot! I really appreciate your dedication to this project. I added below code and error is gone.
if let deletable = self.detail.array as? [KargoDetailCD] {
transaction.delete(deletable)
}
PS: It is not related to this question directly, but is there a way to have a Uniqueness by using multiple fields. Because for this user case, I don't have any ID to differentiate. Something like Hashable protocol maybe?
I am using ImportUniqueObjects extension to import data from the server. If the Store is empty import works but if there is a previous data, following error comes
I know code 1560 is validation error but why it works in the first time but not the second time puzzles me. Error code also shows that parent is nil.
Here is the relevant models