Opened 8 years ago

Closed 5 years ago

#9164 closed Bug (duplicate)

mysql backend, foreign key respect order

Reported by: cristofaro.campagna@… 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)

introspection.py (5.4 KB) - added by cristofaro.campagna@… 8 years ago.
diff-introspection-mysql (1.9 KB) - added by cristofaro.campagna@… 8 years ago.

Download all attachments as: .zip

Change History (7)

Changed 8 years ago by cristofaro.campagna@…

Attachment: introspection.py added

comment:1 Changed 8 years ago by Malcolm Tredinnick

Needs documentation: unset
Needs tests: unset
Patch needs improvement: unset
Triage Stage: UnreviewedAccepted

Please create a diff against the current code so that we can see what changed (run svn diff from 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.

Changed 8 years ago by cristofaro.campagna@…

Attachment: diff-introspection-mysql added

comment:2 Changed 6 years ago by Gabriel Hurley

Component: django-admin.py inspectdbCore (Management commands)

comment:3 Changed 5 years ago by Luke Plant

Severity: Normal
Type: Bug

comment:4 Changed 5 years ago by Ramiro Morales

Easy pickings: unset
Keywords: inspectdb added
UI/UX: unset

comment:5 Changed 5 years ago by Ramiro Morales

Resolution: duplicate
Status: newclosed

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.

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