Opened 18 years ago
Closed 17 years ago
#3549 closed (duplicate)
Models that use GenericRelation generate multiple drop statements in ./manage.sql reset app
Reported by: | Owned by: | nobody | |
---|---|---|---|
Component: | Core (Management commands) | Version: | dev |
Severity: | Keywords: | GenericRelation reset sqlreset ./manage.py | |
Cc: | Triage Stage: | Accepted | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
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.
Attachments (1)
Change History (5)
comment:1 by , 18 years ago
Triage Stage: | Unreviewed → Accepted |
---|
by , 18 years ago
comment:2 by , 18 years ago
Has patch: | set |
---|
comment:3 by , 17 years ago
#3480 has the same root problem. Patch there which may solve the dupe DROP issue a bit more safely than the one here.
Added simple patch that adds a check to make sure the drop statement is unique. This solves the problems i have been running into with generic relations and reset app although there might be a better way to patch this?