[Django] #23028: inspectdb does not check unique_together constraints

21 views
Skip to first unread message

Django

unread,
Jul 14, 2014, 5:51:51 PM7/14/14
to django-...@googlegroups.com
#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.

Django

unread,
Jul 14, 2014, 5:55:12 PM7/14/14
to django-...@googlegroups.com
#23028: inspectdb does not check unique_together constraints
-------------------------------+--------------------------------------

Reporter: anonymous | Owner: nobody
Type: Uncategorized | Status: new
Component: Uncategorized | Version: 1.6
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------------------------
Changes (by dnozay):

* cc: damien.nozay@… (added)
* needs_docs: => 0
* needs_tests: => 0
* needs_better_patch: => 0


Comment:

reported by dnozay.

patch is at https://github.com/django/django/pull/2920.patch

--
Ticket URL: <https://code.djangoproject.com/ticket/23028#comment:1>

Django

unread,
Jul 15, 2014, 8:35:00 AM7/15/14
to django-...@googlegroups.com
#23028: Add unique_together support to inspectdb
-------------------------------------+-------------------------------------
Reporter: anonymous | Owner: nobody
Type: New feature | Status: new
Component: Core (Management | Version: master
commands) | Resolution:
Severity: Normal | Triage Stage: Accepted
Keywords: | Needs documentation: 0
Has patch: 1 | Patch needs improvement: 1
Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------
Changes (by timo):

* needs_better_patch: 0 => 1
* component: Uncategorized => Core (Management commands)
* version: 1.6 => master
* has_patch: 0 => 1
* type: Uncategorized => New feature
* stage: Unreviewed => Accepted


Comment:

Added some comments for improvement on the PR. Please uncheck "Patch needs
improvement" when you update it, thanks.

--
Ticket URL: <https://code.djangoproject.com/ticket/23028#comment:2>

Django

unread,
Jul 21, 2014, 3:18:29 AM7/21/14
to django-...@googlegroups.com
#23028: Add unique_together support to inspectdb
-------------------------------------+-------------------------------------
Reporter: anonymous | Owner: nobody
Type: New feature | Status: closed

Component: Core (Management | Version: master
commands) | Resolution: fixed

Severity: Normal | Triage Stage: Accepted
Keywords: | Needs documentation: 0
Has patch: 1 | Patch needs improvement: 1
Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------
Changes (by Tim Graham <timograham@…>):

* status: new => closed
* resolution: => fixed


Comment:

In [changeset:"70c54a3694975c43a2e0e22c4a90c3cbe1eb54e4"]:
{{{
#!CommitTicketReference repository=""
revision="70c54a3694975c43a2e0e22c4a90c3cbe1eb54e4"
Fixed #23028: Added unique_togther support to inspectdb.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/23028#comment:3>

Reply all
Reply to author
Forward
0 new messages