Modify ↓
Ticket #478 (assigned defect)
db.delete_index() doesn't introspect the database to get the name of index, fails with django 1.2
| Reported by: | gciotta@… | Owned by: | andrew |
|---|---|---|---|
| Priority: | major | Milestone: | 1.0 |
| Component: | databaseapi | Version: | mercurial |
| Keywords: | Cc: |
Description
South uses django < 1.2 conventions to work out names of indexes in db.delete_indexes(), thus failing to get the right indexes with django 1.2. Ideally, it should rely on db introspection instead.
I'm seeing this on mysql, django 1.2, south@tip.
Attachments
Change History
comment:3 Changed 3 years ago by andrew
- Milestone changed from 0.7.2 to 1.0
It seems that it's nigh-on impossible to get index names out of databases using introspection easily, since they're not part of the SQL standard. Having to bump this to 1.0 for now.
comment:4 Changed 2 years ago by claude@…
Just FYI, here is the function I use with MySQL:
def get_index_name(table_name, column_name):
KEY_NAME_IDX = 2
COL_NAME_IDX = 4
saved_dry_run = db.dry_run
db.dry_run = False
res = db.execute('SHOW INDEX FROM %s' % db.quote_name(table_name))
db.dry_run = saved_dry_run
for row in res:
if row[COL_NAME_IDX] == column_name:
return row[KEY_NAME_IDX]
raise Exception("No index found on column %s from table %s" % (column_name, table_name))
Note: See
TracTickets for help on using
tickets.
