Opened 13 years ago

Closed 11 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 Russell Keith-Magee, 13 years ago

Triage Stage: UnreviewedReady for checkin

comment:2 by Luke Plant, 13 years ago

Component: Core frameworkDatabase layer (models, ORM)
Needs documentation: set
Triage Stage: Ready for checkinAccepted

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.

comment:3 by anonymous, 13 years ago

Severity: Normal
Type: Bug

comment:4 by Aymeric Augustin, 12 years ago

UI/UX: unset

Change UI/UX from NULL to False.

comment:5 by Aymeric Augustin, 12 years ago

Easy pickings: unset

Change Easy pickings from NULL to False.

comment:6 by Tim Graham, 11 years ago

Resolution: duplicate
Status: newclosed

Duplicate of #15697 (which has a patch)

Note: See TracTickets for help on using tickets.
Back to Top