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)
Change History (14)
comment:1 by , 14 years ago
Type: | → Bug |
---|
comment:2 by , 14 years ago
Severity: | → Normal |
---|
comment:3 by , 14 years ago
Component: | Uncategorized → Core (Management commands) |
---|---|
milestone: | → 1.4 |
Triage Stage: | Unreviewed → Accepted |
comment:4 by , 13 years ago
Easy pickings: | unset |
---|---|
Owner: | changed from | to
UI/UX: | unset |
by , 13 years ago
Attachment: | ticket15697.diff added |
---|
comment:6 by , 13 years ago
Has patch: | set |
---|---|
Status: | new → assigned |
comment:8 by , 13 years ago
Easy pickings: | set |
---|
comment:9 by , 13 years ago
Needs tests: | set |
---|
comment:11 by , 12 years ago
Needs tests: | unset |
---|---|
Version: | 1.2 |
Pull request added: https://github.com/django/django/pull/346
comment:12 by , 11 years ago
Owner: | changed from | to
---|---|
Version: | → master |
comment:13 by , 11 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
Note:
See TracTickets
for help on using tickets.
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.