#26320: Multi-table inheritance pointer merged with another OneToOneField
-------------------------------------+-------------------------------------
     Reporter:  BertrandBordage      |                    Owner:  nobody
         Type:  Bug                  |                   Status:  new
    Component:  Database layer       |                  Version:  master
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:
     Keywords:                       |             Triage Stage:
                                     |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by timgraham):

 * needs_better_patch:   => 0
 * needs_tests:   => 0
 * needs_docs:   => 0


Comment:

 The promotion of the `OneToOneField` to a `primary_key` happens
 
[https://github.com/django/django/blob/b886f166b332bda96b178a7327a5118f75d804b6/django/db/models/options.py#L239-L250
 in options.py]. I didn't see a mention of the behavior in the
 [https://docs.djangoproject.com/en/dev/topics/db/models/#multi-table-
 inheritance multi-table inheritance docs] but it seems to date to merge of
 the queryset refactor branch in 9c52d56f6f8a9cdafb231adf9f4110473099c9b5.

 I don't know if we can change the behavior but we could at least document
 it.

 Is there some problem defining your model like this:
 {{{
 class Child(Parent):
     parent_ptr = models.OneToOneField(Parent, primary_key=True,
 related_name='+')
     parent_ptr2 = models.OneToOneField(Parent, null=True,
 related_name='+')
 }}}
 I didn't get any check errors in that case but I didn't test any queries.

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

Reply via email to