Models that use GenericRelation generate multiple drop statements in ./manage.sql reset app
|Reported by:||phil.h.smith@…||Owned by:||nobody|
|Component:||Core (Management commands)||Version:||master|
|Severity:||Keywords:||GenericRelation reset sqlreset ./manage.py|
|Has patch:||yes||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
If a model X explicitly defines a GenericRelation to act as the reverse end of a GenericForeignKey from model Y, then the sql generated by ./manage.py reset game will generate an extra DROP TABLE app_Y for each GenericRelation.
I believe the cause is in django.core.management.get_sql_delete, in the many-to-many section around line 307 or so. Model X apparently treats a GenericRelation(Y) as a ManyToManyField(Y) here. This might be appropriate (I don't know), but either way collecting these tables in the set() created above would uniquefy them and solve the issue.
Change History (5)
comment:1 Changed 9 years ago by Simon G. <dev@…>
- Needs documentation unset
- Needs tests unset
- Patch needs improvement unset
- Triage Stage changed from Unreviewed to Accepted