#27742: Unexpected migration on Parent -> child model inheritence
---------------------------------+------------------------------------
Reporter: Anthony King | Owner: nobody
Type: Bug | Status: new
Component: Migrations | Version: 1.11
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
---------------------------------+------------------------------------
Comment (by Tim Graham):
For example with these models:
{{{
from django.db import models
class Parent(models.Model):
pass
class O2OPK(models.Model):
id = models.OneToOneField(Parent, primary_key=True,
on_delete=models.CASCADE)
}}}
and this data:
{{{
from ser.models import Parent, O2OPK
o = O2OPK.objects.create(id=Parent.objects.create())
}}}
`dumpdata` gives:
{{{
[{"model": "ser.parent", "pk": 1, "fields": {}}, {"model": "ser.o2opk",
"pk": 1, "fields": {}}]
}}}
both on 1.10 and after the patch, yet a new migration is required because
`OneToOneField` has `serialize=True` now.
The solution you proposed isn't obviously correct to me. It changes
`serialize` for all `OneToOneField` primary keys to solve a case involving
natural primary keys. If we can avoid it, it would be better if migrations
weren't required for this niche case. I don't much usage experience with
natural keys, and I haven't had time to dig into the issue to propose an
alternative solution. Did you consider alternatives presented in
:ticket:24607#comment:8?
--
Ticket URL: <https://code.djangoproject.com/ticket/27742#comment:10>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/067.9d41d8957158c083d3dbe5490b7e0444%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.