Opened 17 years ago
Closed 14 years ago
#9164 closed Bug (duplicate)
mysql backend, foreign key respect order
| Reported by: | Owned by: | nobody | |
|---|---|---|---|
| Component: | Core (Management commands) | Version: | 1.0 | 
| Severity: | Normal | Keywords: | foreignkey inspectdb | 
| Cc: | Triage Stage: | Accepted | |
| Has patch: | no | Needs documentation: | no | 
| Needs tests: | no | Patch needs improvement: | no | 
| Easy pickings: | no | UI/UX: | no | 
Description
Introspection mysql backend not respect order on foreing key. List of table extract by function get_table_list using "show table", this command not return correct response for goal.
Show tables return list table into db, but these haven't order in models.py definition.
es.
class A(models.Model):
cma = models.ForeignKey(B)
class B(models.Model):
att = models.CharField(max_length=60, blank=True)
In this example B is not define class
For resolve problem i just implemented new introspection.py and attach in this ticket
Bye!
Attachments (2)
Change History (7)
by , 17 years ago
| Attachment: | introspection.py added | 
|---|
comment:1 by , 17 years ago
| Triage Stage: | Unreviewed → Accepted | 
|---|
by , 17 years ago
| Attachment: | diff-introspection-mysql added | 
|---|
comment:2 by , 15 years ago
| Component: | django-admin.py inspectdb → Core (Management commands) | 
|---|
comment:3 by , 14 years ago
| Severity: | → Normal | 
|---|---|
| Type: | → Bug | 
comment:4 by , 14 years ago
| Easy pickings: | unset | 
|---|---|
| Keywords: | inspectdb added | 
| UI/UX: | unset | 
comment:5 by , 14 years ago
| Resolution: | → duplicate | 
|---|---|
| Status: | new → closed | 
I'm going to close this as a duplicate of #15076 that presents and proposes resolution of the same issue but in a non MySQL-specific fashion.
Please create a diff against the current code so that we can see what changed (run
svn difffrom the top of the source tree). It shouldn't need to be a big change to sort things correctly, I would expect. There are at least two ways to do it: sorting the model definitions, or using string names for forwards references when one model comes before another. It's not always possible to sort things so that everything is a backwards reference, so the string names version may be shorter; we'll have to see.