-
Notifications
You must be signed in to change notification settings - Fork 117
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Delete reverse relations before update or create in NestedUpdateMixin #158
Comments
I don't think that there was a specific reason for this particular order. @ruscoder what do you think? |
Hi @ir4y looking into a bit more, I realized that changing the order breaks this:
https://github.com/beda-software/drf-writable-nested/blob/master/drf_writable_nested/mixins.py#L150 Since the object will not exist if we delete it first. But I also don't think it's an odd behavior to delete the object if pk was not given instead of inferring the pk(this is what I would expect). Let me know what do you guys think - I will be happy to shoot a PR |
@gagantrivedi Could you please contribute to https://github.com/beda-software/drf-writable-nested#known-problems-with-solutions by describing your case? |
Hi, is there a reason why we are calling
self.update_or_create_reverse_relations(instance, reverse_relations)
before callingself.delete_reverse_relations_if_need(instance, reverse_relations)
here:
The reason why I am concerned about this is - It violates certain conditions(that I check at the time of object creation using
AFTER_SAVE
hook) in my code by creating the object before deleting the one that needs to be deleted.If there is no reason behind the order, I think we should switch the order to delete first before create/update since it makes logical sense as well?
The text was updated successfully, but these errors were encountered: