From a170dac887ba17afb0adb7a837410dd26471f097 Mon Sep 17 00:00:00 2001 From: Tim Graham Date: Wed, 21 Mar 2018 10:37:56 -0400 Subject: [PATCH] Fixed too many parentheses in inspectdb Meta.unique_together output. Regression in c76d87427d70f6c91ab855ed688828aa982720d2. --- django/core/management/commands/inspectdb.py | 2 +- tests/inspectdb/tests.py | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/django/core/management/commands/inspectdb.py b/django/core/management/commands/inspectdb.py index f093e35be9..31c4ae062b 100644 --- a/django/core/management/commands/inspectdb.py +++ b/django/core/management/commands/inspectdb.py @@ -273,7 +273,7 @@ class Command(BaseCommand): if params['unique']: columns = params['columns'] if len(columns) > 1: - unique_together.append('(' + str(tuple(column_to_field_name[c] for c in columns)) + ')') + unique_together.append(str(tuple(column_to_field_name[c] for c in columns))) managed_comment = " # Created from a view. Don't remove." if is_view else "" meta = ["", " class Meta:", diff --git a/tests/inspectdb/tests.py b/tests/inspectdb/tests.py index db61246c6a..b6bbf0b2dd 100644 --- a/tests/inspectdb/tests.py +++ b/tests/inspectdb/tests.py @@ -211,6 +211,7 @@ class InspectDBTestCase(TestCase): out = StringIO() call_command('inspectdb', 'inspectdb_uniquetogether', stdout=out) output = out.getvalue() + self.assertIn(" unique_together = (('", output) unique_re = re.compile(r'.*unique_together = \((.+),\).*') unique_together_match = re.findall(unique_re, output) # There should be one unique_together tuple.