Opened 14 years ago

Closed 11 years ago

#15697 closed Bug (fixed)

sqlindexes doesn't output index on manytomany tables although syncdb creates it

Reported by: Markus Bertheau Owned by: Claude Paroz
Component: Core (Management commands) Version: dev
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description

Django 1.2.5, Ubuntu 10.10.

With these simple models:

class A(models.Model):
    pass

class B(models.Model):
    a = models.ManyToManyField(A)

./manage.py sqlindexes myapp doesn't output the following CREATE INDEX statement, but ./manage.py syncdb does create them:

CREATE INDEX `myapp_b_a_3797486b` ON `myapp_b_a` (`b_id`);
CREATE INDEX `myapp_b_a_776cf5a8` ON `myapp_b_a` (`a_id`);

Shouldn’t the output of ./manage.py sqlindexes correspond to what ./manage.py syncdb does?

Attachments (1)

ticket15697.diff (712 bytes ) - added by Ash Christopher 13 years ago.

Download all attachments as: .zip

Change History (14)

comment:1 by Luke Plant, 14 years ago

Type: Bug

comment:2 by Luke Plant, 14 years ago

Severity: Normal

comment:3 by Jacob, 14 years ago

Component: UncategorizedCore (Management commands)
milestone: 1.4
Triage Stage: UnreviewedAccepted

comment:4 by Ash Christopher, 13 years ago

Easy pickings: unset
Owner: changed from nobody to Ash Christopher
UI/UX: unset

comment:5 by Ash Christopher, 13 years ago

Took a look at the code:

In syncdb, there are our defined models and there are also models to represent the intermediate tables.

If we use the above example, we define A and B models but when we run syncdb, there is an intermediate model generated called B_a which actually contains the indexes.

When you call sqlindexes, or sql, or sqlall we only ever reference the models defined in our models.py and we don't actually reference the intermediate model.

Version 0, edited 13 years ago by Ash Christopher (next)

by Ash Christopher, 13 years ago

Attachment: ticket15697.diff added

comment:6 by Ash Christopher, 13 years ago

Has patch: set
Status: newassigned

comment:7 by Jacob, 13 years ago

milestone: 1.4

Milestone 1.4 deleted

comment:8 by Ash Christopher, 13 years ago

Easy pickings: set

comment:9 by Claude Paroz, 13 years ago

Needs tests: set

comment:10 by Ash Christopher, 12 years ago

Currently porting patch and adding tests.

comment:11 by Ash Christopher, 12 years ago

Needs tests: unset
Version: 1.2

comment:12 by Claude Paroz, 11 years ago

Owner: changed from Ash Christopher to Claude Paroz
Version: master

comment:13 by Claude Paroz <claude@…>, 11 years ago

Resolution: fixed
Status: assignedclosed

In 8010289ea2f30f0bb819feba7ec78e67c198023b:

Fixed #15697 -- Made sqlindexes aware of auto-created tables

Thanks mbertheau for the report and Ash Christopher for the
initial patch.

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