#19607: prefetch_related crash
-------------------------------------+-------------------------------------
Reporter: av@… | Owner: nobody
Type: Bug | Status: new
Component: Database layer | Version: 1.4
(models, ORM) | Resolution:
Severity: Normal | Triage Stage:
Keywords: prefetch | Unreviewed
prefetch_related | Needs documentation: 0
Has patch: 1 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------
Comment (by kenn.knowles@…):
I mean the +1 to add a vote to the severity of the issue, nothing more.
And you are in luck. My admin cannot be performant without fixing this,
and there is not apparently any workaround, so I am working on isolating
the failure by replicating my project and removing pieces until it is
suitable for public upload. Unfortunately a direct replica with a few
hand-entered models has not caused the error.
Perhaps you can clarify this statement, which might be a clue:
"From what I can tell, you are hitting on a case we are deliberately not
supporting - a lookup that returns heterogeneous set of objects. At each
stage of traversing the prefetch_related chain, the set of objects that
are retrieved must be a homogeneous set of objects."
My case is probably not that complex, so I doubt it applies
{{{
class Person(Model):
...
class Relation1(Model):
person1 = ForeignKey(Person, related_name='relation1_as_person1')
person2 = ForeignKey(Person, related_name='relation1_as_person2')
class Relation2(Model):
person1 = ForeignKey(Person, related_name='relation2_as_person1')
person2 = ForeignKey(Person, related_name='relation2_as_person2')
relation1 = ForeignKey(Relation1)
}}}
And this always crashes, but apparently requires some involved data to
trigger:
{{{
Relation2.objects.prefetch_related(
'person1',
'person2',
'relation1',
'relation1__person1',
'relation1__person2',
'person1__relation1_as_person1',
'person2__relation1_as_person2'
)
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/19607#comment:16>
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.bd8d7c3b6dbf03ca764cc8bb9548a46a%40djangoproject.com?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.