mirror of https://github.com/django/django.git
Fixed #28152 -- Made migrations serialize sets as set literals rather than set().
This commit is contained in:
parent
912ef7f49d
commit
f599747fc8
|
@ -26,7 +26,7 @@ class Migration(migrations.Migration):
|
||||||
],
|
],
|
||||||
options={
|
options={
|
||||||
'ordering': ('content_type__app_label', 'content_type__model', 'codename'),
|
'ordering': ('content_type__app_label', 'content_type__model', 'codename'),
|
||||||
'unique_together': set([('content_type', 'codename')]),
|
'unique_together': {('content_type', 'codename')},
|
||||||
'verbose_name': 'permission',
|
'verbose_name': 'permission',
|
||||||
'verbose_name_plural': 'permissions',
|
'verbose_name_plural': 'permissions',
|
||||||
},
|
},
|
||||||
|
|
|
@ -29,6 +29,6 @@ class Migration(migrations.Migration):
|
||||||
),
|
),
|
||||||
migrations.AlterUniqueTogether(
|
migrations.AlterUniqueTogether(
|
||||||
name='contenttype',
|
name='contenttype',
|
||||||
unique_together=set([('app_label', 'model')]),
|
unique_together={('app_label', 'model')},
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
|
|
|
@ -30,7 +30,7 @@ class Migration(migrations.Migration):
|
||||||
],
|
],
|
||||||
options={
|
options={
|
||||||
'ordering': ('old_path',),
|
'ordering': ('old_path',),
|
||||||
'unique_together': set([('site', 'old_path')]),
|
'unique_together': {('site', 'old_path')},
|
||||||
'db_table': 'django_redirect',
|
'db_table': 'django_redirect',
|
||||||
'verbose_name': 'redirect',
|
'verbose_name': 'redirect',
|
||||||
'verbose_name_plural': 'redirects',
|
'verbose_name_plural': 'redirects',
|
||||||
|
|
|
@ -244,8 +244,9 @@ class SequenceSerializer(BaseSequenceSerializer):
|
||||||
|
|
||||||
class SetSerializer(BaseSequenceSerializer):
|
class SetSerializer(BaseSequenceSerializer):
|
||||||
def _format(self):
|
def _format(self):
|
||||||
# Don't use the literal "{%s}" as it doesn't support empty set
|
# Serialize as a set literal except when value is empty because {}
|
||||||
return "set([%s])"
|
# is an empty dict.
|
||||||
|
return '{%s}' if self.value else 'set(%s)'
|
||||||
|
|
||||||
|
|
||||||
class SettingsReferenceSerializer(BaseSerializer):
|
class SettingsReferenceSerializer(BaseSerializer):
|
||||||
|
|
|
@ -30,6 +30,6 @@ class Migration(migrations.Migration):
|
||||||
),
|
),
|
||||||
migrations.AlterUniqueTogether(
|
migrations.AlterUniqueTogether(
|
||||||
name='author',
|
name='author',
|
||||||
unique_together=set([('name', 'slug')]),
|
unique_together={('name', 'slug')},
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
|
|
|
@ -25,6 +25,6 @@ class Migration(migrations.Migration):
|
||||||
),
|
),
|
||||||
migrations.AlterUniqueTogether(
|
migrations.AlterUniqueTogether(
|
||||||
name='author',
|
name='author',
|
||||||
unique_together=set([('name', 'slug')]),
|
unique_together={('name', 'slug')},
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
|
|
|
@ -25,6 +25,6 @@ class Migration(migrations.Migration):
|
||||||
),
|
),
|
||||||
migrations.AlterUniqueTogether(
|
migrations.AlterUniqueTogether(
|
||||||
name='author',
|
name='author',
|
||||||
unique_together=set([('name', 'slug')]),
|
unique_together={('name', 'slug')},
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
|
|
|
@ -505,6 +505,12 @@ class WriterTests(SimpleTestCase):
|
||||||
self.assertSerializedEqual(frozenset())
|
self.assertSerializedEqual(frozenset())
|
||||||
self.assertSerializedEqual(frozenset("let it go"))
|
self.assertSerializedEqual(frozenset("let it go"))
|
||||||
|
|
||||||
|
def test_serialize_set(self):
|
||||||
|
self.assertSerializedEqual(set())
|
||||||
|
self.assertSerializedResultEqual(set(), ('set()', set()))
|
||||||
|
self.assertSerializedEqual({'a'})
|
||||||
|
self.assertSerializedResultEqual({'a'}, ("{'a'}", set()))
|
||||||
|
|
||||||
def test_serialize_timedelta(self):
|
def test_serialize_timedelta(self):
|
||||||
self.assertSerializedEqual(datetime.timedelta())
|
self.assertSerializedEqual(datetime.timedelta())
|
||||||
self.assertSerializedEqual(datetime.timedelta(minutes=42))
|
self.assertSerializedEqual(datetime.timedelta(minutes=42))
|
||||||
|
|
Loading…
Reference in New Issue