#14226: Bug in dumpdata dependency calculation involving ManyToManyFields
-------------------------------------+-------------------------------------
Reporter: aneil | Owner: koirikivi
Type: Bug | Status: assigned
Component: Core | Version: 1.2
(Serialization) | Resolution:
Severity: Normal | Triage Stage: Accepted
Keywords: easy-pickings | Needs documentation: 0
Has patch: 1 | Patch needs improvement: 1
Needs tests: 0 | UI/UX: 0
Easy pickings: 1 |
-------------------------------------+-------------------------------------
Comment (by koirikivi):
I think the correct way to fix this is to remove models referenced by
complex (with explicit intermediate models i.e. through=...) M2M relations
from the dependency chain, but keep simple (with automatic intermediate
models) in the dependency chain.
This is also the check done by
django.core.serializers.python.Serializer.handle_m2m_field. In serialized
data, simple M2M relations are shown inline with the model that defines
them, which makes dependencies of the referenced models. For complex M2M
relations, however, the intermediate models should be serialized along
with the other models, and should be included as models in the serialized
data. The model defining the M2M relation thus has no dependency to the
other model, but the intermediate model will have a dependency to both of
the M2M models.
Development branch at
https://github.com/koirikivi/django/tree/ticket_14226
Pull request at https://github.com/django/django/pull/1495
All tests pass under sqlite and postgres.
I created quite a few tests to first learn about the issue and then to be
sure that everything works. The ''test_dump_and_load_m2m_complex_*'' tests
are most likely redundant with the other tests in the PR, and can be
removed as seemed fit.
FWIW I also tried the patch posted by aneil, which broke a couple of
tests, and removing the M2M checks altogether, which didn't break any
tests but resulted in a regression that's caught in the tests in the PR
(namely ''test_dependency_sorting_m2m_simple'')
--
Ticket URL: <https://code.djangoproject.com/ticket/14226#comment:13>
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/063.3446b87c7de987194fdeb4ed8e50b63c%40djangoproject.com.
For more options, visit https://groups.google.com/groups/opt_out.