dumpdata crashes on querysets with prefetch_related().
The ./manage.py dumpdata management command calls iterator() on the QuerySets of the models, but it does not pass chunk_size(https://github.com/django/django/blob/main/django/core/management/commands/dumpdata.py#L222). On model QuerySets that include prefetch_related, this now (with 5.0) causes this error while running dumpdata:
CommandError: Unable to serialize database: chunk_size must be provided when using QuerySet.iterator() after prefetch_related().
Proposed fix is to pass a suitable chunk_size parameter to iterator() within handle() in dumpdata.py.
Change History
(7)
| Owner: |
changed from nobody to yushan
|
| Status: |
new → assigned
|
| Cc: |
Jacob Walls Raphael Kimmig Simon Charette added
|
| Easy pickings: |
unset
|
| Severity: |
Normal → Release blocker
|
| Summary: |
dumpdata does not work in 5.0.1 on QuerySets with prefetch_related → dumpdata crashes on querysets with prefetch_related().
|
| Triage Stage: |
Unreviewed → Accepted
|
| Owner: |
changed from yushan to Mariusz Felisiak
|
| Resolution: |
→ fixed
|
| Status: |
assigned → closed
|
Thanks for the report. Does the following patch work for you?
django/core/management/commands/dumpdata.py
Regression in 139135627650ed6aaaf4c755b82c3bd43f2b8f51 (#29984).