Loading django/db/migrations/state.py +3 −2 Original line number Diff line number Diff line from django.db import models from django.db.models.loading import BaseAppCache from django.db.models.options import DEFAULT_NAMES from django.db.models.options import DEFAULT_NAMES, normalize_unique_together from django.utils import six from django.utils.module_loading import import_by_path Loading Loading @@ -127,7 +127,8 @@ class ModelState(object): continue elif name in model._meta.original_attrs: if name == "unique_together": options[name] = set(model._meta.original_attrs["unique_together"]) ut = model._meta.original_attrs["unique_together"] options[name] = set(normalize_unique_together(ut)) else: options[name] = model._meta.original_attrs[name] # Make our record Loading django/db/models/options.py +6 −3 Original line number Diff line number Diff line Loading @@ -32,10 +32,13 @@ def normalize_unique_together(unique_together): tuple of two strings. Normalize it to a tuple of tuples, so that calling code can uniformly expect that. """ unique_together = tuple(unique_together) if unique_together and not isinstance(unique_together[0], (tuple, list)): if not unique_together: return () first_element = next(iter(unique_together)) if not isinstance(first_element, (tuple, list)): unique_together = (unique_together,) return unique_together # Normalize everything to tuples return tuple(tuple(ut) for ut in unique_together) @python_2_unicode_compatible Loading tests/migrations/test_state.py +1 −1 Original line number Diff line number Diff line Loading @@ -55,7 +55,7 @@ class StateTests(TestCase): self.assertEqual(author_state.fields[1][1].max_length, 255) self.assertEqual(author_state.fields[2][1].null, False) self.assertEqual(author_state.fields[3][1].null, True) self.assertEqual(author_state.options, {"unique_together": set(("name", "bio"))}) self.assertEqual(author_state.options, {"unique_together": {("name", "bio")}}) self.assertEqual(author_state.bases, (models.Model, )) self.assertEqual(book_state.app_label, "migrations") Loading Loading
django/db/migrations/state.py +3 −2 Original line number Diff line number Diff line from django.db import models from django.db.models.loading import BaseAppCache from django.db.models.options import DEFAULT_NAMES from django.db.models.options import DEFAULT_NAMES, normalize_unique_together from django.utils import six from django.utils.module_loading import import_by_path Loading Loading @@ -127,7 +127,8 @@ class ModelState(object): continue elif name in model._meta.original_attrs: if name == "unique_together": options[name] = set(model._meta.original_attrs["unique_together"]) ut = model._meta.original_attrs["unique_together"] options[name] = set(normalize_unique_together(ut)) else: options[name] = model._meta.original_attrs[name] # Make our record Loading
django/db/models/options.py +6 −3 Original line number Diff line number Diff line Loading @@ -32,10 +32,13 @@ def normalize_unique_together(unique_together): tuple of two strings. Normalize it to a tuple of tuples, so that calling code can uniformly expect that. """ unique_together = tuple(unique_together) if unique_together and not isinstance(unique_together[0], (tuple, list)): if not unique_together: return () first_element = next(iter(unique_together)) if not isinstance(first_element, (tuple, list)): unique_together = (unique_together,) return unique_together # Normalize everything to tuples return tuple(tuple(ut) for ut in unique_together) @python_2_unicode_compatible Loading
tests/migrations/test_state.py +1 −1 Original line number Diff line number Diff line Loading @@ -55,7 +55,7 @@ class StateTests(TestCase): self.assertEqual(author_state.fields[1][1].max_length, 255) self.assertEqual(author_state.fields[2][1].null, False) self.assertEqual(author_state.fields[3][1].null, True) self.assertEqual(author_state.options, {"unique_together": set(("name", "bio"))}) self.assertEqual(author_state.options, {"unique_together": {("name", "bio")}}) self.assertEqual(author_state.bases, (models.Model, )) self.assertEqual(book_state.app_label, "migrations") Loading