You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using multi-table inheritance in Django 3.2, editing objects triggers an OperationalError: duplicate primary key given error. The edit succeeds behind the scenes. This works with MySQL 8.0.11.
I'm curious why in this case Django evaluated to doing an INSERT. We'll need to dig into this more on our end. I do believe however adding force_update=True on save would solve your problem as well.
Description
When using multi-table inheritance in Django 3.2, editing objects triggers an
OperationalError: duplicate primary key given
error. The edit succeeds behind the scenes. This works with MySQL 8.0.11.Steps to reproduce
This is a minimal test case to reproduce:
app/models.py:
Shell:
Offending query in Dolt log:
This
INSERT
is never attempted when connected to MySQL proper, I'm guessing a result of a previous query tricks Django into attempting an INSERT.Workaround
By setting
select_on_save = True
in Child.Meta, restoring pre-1.6 behavior, no error is triggered:https://docs.djangoproject.com/en/3.2/ref/models/options/#select-on-save
app/models.py
The text was updated successfully, but these errors were encountered: