#35159: dumpdata crashes on querysets with prefetch_related().
-------------------------------------+-------------------------------------
     Reporter:  Andrea F             |                    Owner:  yushan
         Type:  Bug                  |                   Status:  assigned
    Component:  Core (Management     |                  Version:  5.0
  commands)                          |
     Severity:  Release blocker      |               Resolution:
     Keywords:  dumpdata chunk_size  |             Triage Stage:  Accepted
  iterator prefetch_related          |
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

 * cc: Jacob Walls, Raphael Kimmig, Simon Charette (added)
 * summary:  dumpdata does not work in 5.0.1 on QuerySets with
     prefetch_related => dumpdata crashes on querysets with
     prefetch_related().
 * severity:  Normal => Release blocker
 * easy:  1 => 0
 * stage:  Unreviewed => Accepted

Comment:

 Thanks for the report. Does the following patch work for you?
 {{{#!diff
 diff --git a/django/core/management/commands/dumpdata.py
 b/django/core/management/commands/dumpdata.py
 index cc183517e3..01ff8974dd 100644
 --- a/django/core/management/commands/dumpdata.py
 +++ b/django/core/management/commands/dumpdata.py
 @@ -219,7 +219,10 @@ class Command(BaseCommand):
                      if count_only:
                          yield queryset.order_by().count()
                      else:
 -                        yield from queryset.iterator()
 +                        chunk_size = (
 +                            2000 if queryset._prefetch_related_lookups
 else None
 +                        )
 +                        yield from
 queryset.iterator(chunk_size=chunk_size)

          try:
              self.stdout.ending = None

 }}}
 Regression in 139135627650ed6aaaf4c755b82c3bd43f2b8f51 (#29984).
-- 
Ticket URL: <https://code.djangoproject.com/ticket/35159#comment:2>
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/0107018d5ddf287f-6a3eb818-65b3-4aba-a739-852062533506-000000%40eu-central-1.amazonses.com.

Reply via email to