Skip to content
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

IntegrityError on saving a related instance with unique=True on the relation field or on a OneToOneField #118

Open
int-ua opened this issue Mar 22, 2017 · 3 comments

Comments

@int-ua
Copy link
Contributor

int-ua commented Mar 22, 2017

When both master and other have related OneToOne objects:

IntegrityError: duplicate key value violates unique constraint
"common_relatedmodel_connection_id_########_uniq"
DETAIL:  Key (connection_id)=(20147) already exists

Any ideas on a solution or a workaround?

@int-ua int-ua changed the title IntegrityError on saving a related instance with unique=True on the relation field IntegrityError on saving a related instance with unique=True on the relation field or on a OneToOneField Mar 22, 2017
@int-ua
Copy link
Contributor Author

int-ua commented Mar 22, 2017

Also, test_merge_one_to_one_field isn't testing OneToOneField, LogEntry is connected to user through a ForeignKey at least in Django 1.8.

@saxix
Copy link
Owner

saxix commented Mar 23, 2017

do not see how to solve this with code. Seems an invalid "business" scenario, we can only catch the error and let the user fix the merge, removing (blanking) one of the field.

@chrisgrande
Copy link

Just ran into this myself after testing implementing this into a project.

My suggested implementation would be if the the resulting unique records would match that the record that is trying to be changed should be deleted. If the records don't match then the two records could be then displayed in the same merge interface.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants