mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
Fixed #33670 -- Fixed altering primary key on SQLite.
This commit is contained in:
@@ -3584,6 +3584,21 @@ class SchemaTests(TransactionTestCase):
|
||||
)
|
||||
self.assertEqual(self.get_primary_key(Tag._meta.db_table), "slug")
|
||||
|
||||
def test_alter_primary_key_the_same_name(self):
|
||||
with connection.schema_editor() as editor:
|
||||
editor.create_model(Thing)
|
||||
|
||||
old_field = Thing._meta.get_field("when")
|
||||
new_field = CharField(max_length=2, primary_key=True)
|
||||
new_field.set_attributes_from_name("when")
|
||||
new_field.model = Thing
|
||||
with connection.schema_editor() as editor:
|
||||
editor.alter_field(Thing, old_field, new_field, strict=True)
|
||||
self.assertEqual(self.get_primary_key(Thing._meta.db_table), "when")
|
||||
with connection.schema_editor() as editor:
|
||||
editor.alter_field(Thing, new_field, old_field, strict=True)
|
||||
self.assertEqual(self.get_primary_key(Thing._meta.db_table), "when")
|
||||
|
||||
def test_context_manager_exit(self):
|
||||
"""
|
||||
Ensures transaction is correctly closed when an error occurs
|
||||
|
||||
Reference in New Issue
Block a user