#13781: select_related and multiple inheritance
-------------------------------------+-------------------------------------
     Reporter:  shauncutts           |                    Owner:  nobody
         Type:  Bug                  |                   Status:  reopened
    Component:  Database layer       |                  Version:  1.2
  (models, ORM)                      |               Resolution:
     Severity:  Normal               |             Triage Stage:  Accepted
     Keywords:                       |      Needs documentation:  0
    Has patch:  0                    |  Patch needs improvement:  0
  Needs tests:  0                    |                    UI/UX:  0
Easy pickings:  0                    |
-------------------------------------+-------------------------------------

Comment (by ungenio):

 I've created a couple tests. The version with select_related fails, and
 the version without doesn't.

 Description: If Child1 has a OneToOneField to Parent1 and if Child1 is a
 subclass of Parent2, doing Parent1.objects.select_related('child1') will
 produce this traceback:
 {{{
 ======================================================================
 ERROR: test_subclass_with_select_related
 (modeltests.select_related.tests.SelectRelatedTests)
 ----------------------------------------------------------------------
 Traceback (most recent call last):
   File "/Users/david/Projects/django-
 trunk/tests/modeltests/select_related/tests.py", line 171, in
 test_subclass_with_select_related
     p = Parent1.objects.select_related('child1').get(name="Parent1")
   File "/Users/david/Projects/django-trunk/django/db/models/query.py",
 line 361, in get
     num = len(clone)
   File "/Users/david/Projects/django-trunk/django/db/models/query.py",
 line 85, in __len__
     self._result_cache = list(self.iterator())
   File "/Users/david/Projects/django-trunk/django/db/models/query.py",
 line 294, in iterator
     offset=len(aggregate_select))
   File "/Users/david/Projects/django-trunk/django/db/models/query.py",
 line 1420, in get_cached_row
     setattr(rel_obj, rel_field.attname, getattr(obj, rel_field.attname))
 AttributeError: 'Parent1' object has no attribute 'subname'

 ----------------------------------------------------------------------
 }}}

 The same issue occurs if you subclass from both Parent1 and Parent2, but I
 wanted to demonstrate that there is still a problem with just a single
 subclass.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/13781#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 post to this group, send email to django-updates@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.

Reply via email to