#25274: inspectdb does not properly handle renamed fields for unique_together
-------------------------------------+-------------------------------------
     Reporter:  johnmoore            |      Owner:  nobody
         Type:  Uncategorized        |     Status:  new
    Component:  Core (Management     |    Version:  1.8
  commands)                          |   Keywords:  inspectdb,
     Severity:  Normal               |  unique_together
 Triage Stage:  Unreviewed           |  Has patch:  0
Easy pickings:  1                    |      UI/UX:  0
-------------------------------------+-------------------------------------
 When I last used inspectdb, a field named "from" in a table was renamed
 automatically to "from_field." There was a comment in the output: "Field
 renamed because it was a Python reserved word." But for the
 unique_together meta property for that model, the "from" field name was
 used, not the "from_field" name. Thus I received an error when using
 runserver: "'unique_together' refers to the non-existent field 'from'."

 The original issue for adding unique_together support is #23028, I
 believe.

 Here's an example of what I mean:

 {{{

 class PsSpecificPrice(models.Model):
     . . .
     from_field = models.DateTimeField(db_column='from')  # Field renamed
 because it was a Python reserved word.
     to = models.DateTimeField()

     class Meta:
         managed = False
         db_table = 'ps_specific_price'
         unique_together = ((. . . 'from', 'to'),)
 }}}

--
Ticket URL: <https://code.djangoproject.com/ticket/25274>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/052.6fa4bf4420e1d1270c2f66bb88ba2d6d%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to