-
Notifications
You must be signed in to change notification settings - Fork 116
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
Make nested object deletion extensible #143
Conversation
It's currently possible to extend create and update functionality by just implementing those methods on the child serializer, but deletion is a bit trickier. This proposed refactor exposes just the place in the code where deletion takes place so that more functionality can be easily added in user code if desired. For my particular use case, I want to be able to create events and update inventory any time a nested item is deleted. With this new change, I can simply extend ``perform_nested_delete(pks_to_delete, **kwargs)`` to include my functionality and call super() to ensure the deletion takes place as expected. As a side effect, this enables users to adopt functionality proposed in beda-software#103 and beda-software#112 until the PRs are accepted/declined.
Codecov Report
@@ Coverage Diff @@
## master #143 +/- ##
==========================================
+ Coverage 98.16% 98.18% +0.01%
==========================================
Files 3 3
Lines 218 220 +2
==========================================
+ Hits 214 216 +2
Misses 4 4
Continue to review full report at Codecov.
|
@ruscoder I'm hoping this can get merged quickly, as it's a small refactor that provides a lot of value. Let me know if there are any changes you might want me to make and I'll get on them right away. |
Hi @kavdev! Thanks for the contribution. Seems a good general solution for now. |
I'm not sure that perform_nested_delete is good for public usage due to a lot of arguments, but maybe it can be good for extensibility. Merged |
Available in 0.6.3 |
@ruscoder fantastic, thanks! |
It's currently possible to extend create and update functionality by just implementing those methods on the child serializer, but deletion is a bit trickier.
This proposed refactor exposes just the place in the code where deletion takes place so that more functionality can be easily added in user code if desired.
For my particular use case, I want to be able to create events and update inventory any time a nested item is deleted. With this new change, I can simply extend
perform_nested_delete(pks_to_delete, *args)
to include my functionality and call super() to ensure the deletion takes place as expected.As a side effect, this enables users to adopt functionality proposed in #103 and #112 until the PRs are accepted/declined.