Opened 17 years ago

Closed 17 years ago

#5729 closed (fixed)

Django doesn't create real foreign keys when using MySQL INNODB engine

Reported by: mattdennewitz Owned by: Malcolm Tredinnick
Component: Database layer (models, ORM) Version: dev
Severity: Keywords:
Cc: mir@… Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

When specifying in DATABASE_OPTIONS to use MySQL's INNODB engine, Django will oblige and create the tables using MySQL. It won't, however, create real foreign keys; instead, it adds indexes as though it were using MyISAM.

Change History (4)

comment:1 by Malcolm Tredinnick, 17 years ago

Owner: changed from nobody to Malcolm Tredinnick
Triage Stage: UnreviewedAccepted

Yep. I noticed this recently when switching to MySQL for a project. I've got a fix for this that I've been debugging in my local tree. I'll commit it shortly.

One day the MySQL devs will really have to implement the correct syntax handling. :-(

comment:2 by Michael Radziej, 17 years ago

Cc: mir@… added

comment:3 by mattdennewitz, 17 years ago

thanks!

comment:4 by Malcolm Tredinnick, 17 years ago

Resolution: fixed
Status: newclosed

(In [6650]) Fixed #5729 -- For MySQL (only), always delay the creation of foreign key
references, for all tables, until after the table has been created. This means
that when using the InnoDB storage engine, true foreign key constraints are
created (inline "REFERENCES" are ignored by InnoDB, unfortunately).

Fully backwards compatible.

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