Fix batch deleting current user while it has muted users attached to it #3507
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
🎯 Goal
Describe why we are making this change.
📝 Summary
CurrentUserDTO.mutedUsers
's deletion rule was changed from cascade to nullify. This in turn requires that relationships have the optional check enabled in the model, which we did not have the deletion rule change. This triggered the error.🛠 Implementation
[ChatClient.swift:496] [logout(completion:)] > Logging out current user failed with error Error Domain=NSCocoaErrorDomain Code=134050 "Constraint trigger violation: Batch delete failed due to mandatory MTM nullify inverse on CurrentUserDTO/mutedUsers" UserInfo={NSExceptionOmitCallstacks=true, NSLocalizedFailureReason=Constraint trigger violation: Batch delete failed due to mandatory MTM nullify inverse on CurrentUserDTO/mutedUsers, _NSCoreDataOptimisticLockingFailureConflictsKey=( )}
🎨 Showcase
Add relevant screenshots and/or videos/gifs to easily see what this PR changes, if applicable.
🧪 Manual Testing Notes
Explain how this change can be tested manually, if applicable.
☑️ Contributor Checklist
🎁 Meme
Provide a funny gif or image that relates to your work on this pull request. (Optional)