Opened 14 years ago
Closed 12 years ago
#15033 closed Bug (duplicate)
sqlindexes doesn't create indexes for ForeignKeys on normal ManyToManyFields
Reported by: | Craig de Stigter | Owned by: | nobody |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | 1.2 |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Accepted | |
Has patch: | yes | Needs documentation: | yes |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
this comment implies that the ForeignKeys created by ManyToManyField tables should also have indexes (makes sense, right? Otherwise we'll have to always create them with custom SQL, or define a through relation every time, gross.)
However sqlindexes doesn't create the indexes. It does create the (from, to) unique constraints, but that's actually not very useful for many queries...
The fix is to change django/core/management/sql.py#L140:
for model in models.get_models(app):
to:
for model in models.get_models(app, include_auto_created=True):
Tested in 1.2.4 and trunk (r15153).
Change History (6)
comment:1 by , 14 years ago
Triage Stage: | Unreviewed → Ready for checkin |
---|
comment:2 by , 14 years ago
Component: | Core framework → Database layer (models, ORM) |
---|---|
Needs documentation: | set |
Triage Stage: | Ready for checkin → Accepted |
comment:3 by , 14 years ago
Severity: | → Normal |
---|---|
Type: | → Bug |
comment:6 by , 12 years ago
Resolution: | → duplicate |
---|---|
Status: | new → closed |
Duplicate of #15697 (which has a patch)
I think this needs a documentation change, like the note about the new index here: http://docs.djangoproject.com/en/dev/releases/1.3/#new-index-on-database-session-table
I'm guessing Russell overlooked that, or clicked 'Ready for checkin' instead of 'Accepted', and I'll adjust as I think necessary - apologies to Russell if I've misunderstood something.