From 225c413b08b3e034604ffbaed604a6867d7b712e Mon Sep 17 00:00:00 2001 From: Joseph Kocherhans Date: Wed, 10 Feb 2010 00:49:33 +0000 Subject: [PATCH] =?UTF-8?q?Fixed=20#12647.=20Allow=20unique=5Ftogether=20c?= =?UTF-8?q?hecks=20be=20specified=20as=20lists=20as=20well=20as=20tuples.?= =?UTF-8?q?=20Thanks,=20Honza=20Kr=C3=A1l.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: http://code.djangoproject.com/svn/django/trunk@12403 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/db/models/base.py | 2 +- tests/modeltests/validation/models.py | 2 +- tests/modeltests/validation/test_unique.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/django/db/models/base.py b/django/db/models/base.py index dc4b8f0e7b..449c41a3b4 100644 --- a/django/db/models/base.py +++ b/django/db/models/base.py @@ -683,7 +683,7 @@ class Model(object): if name in exclude: break else: - unique_checks.append(check) + unique_checks.append(tuple(check)) # These are checks for the unique_for_. date_checks = [] diff --git a/tests/modeltests/validation/models.py b/tests/modeltests/validation/models.py index 559658ef6d..dd42936885 100644 --- a/tests/modeltests/validation/models.py +++ b/tests/modeltests/validation/models.py @@ -36,7 +36,7 @@ class UniqueTogetherModel(models.Model): efield = models.EmailField() class Meta: - unique_together = (('ifield', 'cfield',), ('ifield', 'efield')) + unique_together = (('ifield', 'cfield',), ['ifield', 'efield']) class UniqueForDateModel(models.Model): start_date = models.DateField() diff --git a/tests/modeltests/validation/test_unique.py b/tests/modeltests/validation/test_unique.py index 2d67a0a296..ebda9abe77 100644 --- a/tests/modeltests/validation/test_unique.py +++ b/tests/modeltests/validation/test_unique.py @@ -13,7 +13,7 @@ class GetUniqueCheckTests(unittest.TestCase): m._get_unique_checks() ) - def test_unique_together_gets_picked_up(self): + def test_unique_together_gets_picked_up_and_converted_to_tuple(self): m = UniqueTogetherModel() self.assertEqual( ([('ifield', 'cfield',),('ifield', 'efield'), ('id',), ], []),