#23028: inspectdb does not check unique_together constraints
-------------------------------+--------------------
     Reporter:  anonymous      |      Owner:  nobody
         Type:  Uncategorized  |     Status:  new
    Component:  Uncategorized  |    Version:  1.6
     Severity:  Normal         |   Keywords:
 Triage Stage:  Unreviewed     |  Has patch:  0
Easy pickings:  0              |      UI/UX:  0
-------------------------------+--------------------
 `django/db/backends/mysql/introspection.py` has a `get_constraints()`
 method.

 This is what `get_indexes()` would return
 {{{
 {u'commit': {'primary_key': False, 'unique': False},
  u'repository': {'primary_key': False, 'unique': False}}
 }}}

 This is what `get_constraints()` would return
 {{{
 {u'commit_index': {'check': False,
                    'columns': [u'commit'],
                    'foreign_key': None,
                    'index': True,
                    'primary_key': False,
                    'unique': False},
  u'repo_index': {'check': False,
                  'columns': [u'repository'],
                  'foreign_key': None,
                  'index': True,
                  'primary_key': False,
                  'unique': False},
  u'unique_build': {'check': False,
                    'columns': [u'number', u'jobname', u'repository'],
                    'foreign_key': None,
                    'index': True,
                    'primary_key': False,
                    'unique': True}}
 }}}

 This is what `manage.py inspectdb` currently returns
 {{{
 class Builds(models.Model):
     number = models.IntegerField(blank=True, null=True)
     jobname = models.CharField(max_length=64)
     repository = models.CharField(max_length=64)
     commit = models.CharField(max_length=40)
     class Meta:
         managed = False
         db_table = 'builds'
 }}}

 it could be smarter and invoke `get_constaints()` to add the correct
 `unique_together` clause in `Meta`.
 {{{
 unique_together = ((u'number', u'jobname', u'repository'),)
 }}}

-- 
Ticket URL: <https://code.djangoproject.com/ticket/23028>
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.d67902c211831bc36a487ab4343d6a09%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to