#26320: Multi-table inheritance pointer merged with another OneToOneField
----------------------------------------------+--------------------
     Reporter:  BertrandBordage               |      Owner:  nobody
         Type:  Bug                           |     Status:  new
    Component:  Database layer (models, ORM)  |    Version:  master
     Severity:  Normal                        |   Keywords:
 Triage Stage:  Unreviewed                    |  Has patch:  0
Easy pickings:  0                             |      UI/UX:  0
----------------------------------------------+--------------------
 Suppose we have these models:
 {{{#!python
 class Parent(Model):
     pass

 class Child(Parent):
     parent_ptr2 = OneToOneField(Parent, null=True, related_name='+')
 }}}

 `Child` should have two `OneToOneField`s, `parent_ptr` and `parent_ptr2`.
 Unfortunately, Django has a critical issue where it merges these two
 fields into this:
 {{{#!python
 parent_ptr2 = OneToOneField(Parent, primary_key=True, null=True,
 related_name='+')
 }}}
 And of course, a nullable primary key is impossible, so we can’t even do a
 migration: `fields.E007` is raised.
 But defining without multi-table inheritance exactly the same model – in
 terms of database definition – works just fine:
 {{{#!python
 class WorkingModel(Model):
     parent_ptr = OneToOneField(Parent, primary_key=True, related_name='+')
     parent_ptr2 = OneToOneField(Parent, null=True, related_name='+')
 }}}
 So multi-table inheritance is probably what causes this confusion.
 This bug is present on all supported Django versions, from 1.8 to 1.9.3.

 I guess this can be seen as a release blocker, there is no regression but
 this is quite critical (and blocking, in my case).

--
Ticket URL: <https://code.djangoproject.com/ticket/26320>
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/058.cdef1019012d5d7b4fd0ef0b97bc9850%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to