-
-
Notifications
You must be signed in to change notification settings - Fork 25
Fix: Save duplicated objects after foreign keys updated #633
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for implementing a fix, could you ensure that the test covers your changes.
|
Hey @jackton1 , came across this bug while using django-clone, let me know what you think of the fix |
Codecov Report
@@ Coverage Diff @@
## main #633 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 5 5
Lines 287 288 +1
=========================================
+ Hits 287 288 +1
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
|
@all-contributors please add @Akollek for code bug test |
|
I've put up a pull request to add @Akollek! 🎉 |
LGTM, Thanks for updating the test |
The problem
It seems that when copying a many to one relationship a duplicate of the other object is created, but the foreign key change on the original object isn't saved. This evaded being caught by tests since the unsaved object was used for comparison.
The solution
Save the object again after coping all foreign keys.