Code

Opened 6 years ago

Closed 2 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@… 6 years ago.
diff-introspection-mysql (1.9 KB) - added by cristofaro.campagna@… 6 years ago.

Download all attachments as: .zip

Change History (7)

Changed 6 years ago by cristofaro.campagna@…

comment:1 Changed 6 years ago by mtredinnick

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

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 6 years ago by cristofaro.campagna@…

comment:2 Changed 3 years ago by gabrielhurley

  • Component changed from django-admin.py inspectdb to Core (Management commands)

comment:3 Changed 3 years ago by lukeplant

  • Severity set to Normal
  • Type set to Bug

comment:4 Changed 3 years ago by ramiro

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

comment:5 Changed 2 years ago by ramiro

  • Resolution set to duplicate
  • Status changed from new to 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.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.