summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMariusz Felisiak <felisiak.mariusz@gmail.com>2019-09-11 13:40:49 +0200
committerGitHub <noreply@github.com>2019-09-11 13:40:49 +0200
commitc8250ef361dcb4c7ed76632e4308c6db22da77d0 (patch)
tree3359e9bb9bc730906c2cc1f2894af4370afcdc5b
parent937ddaff55efbfb4a9560603bbc8c5b17d9e1364 (diff)
Refs #27338 -- Added tests for altering CharField with primary_key=True to AutoField on PostgreSQL.
Fixed in 91b2bc3e70be2632baad86488fb03cf02848b5b6.
-rw-r--r--tests/schema/tests.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/schema/tests.py b/tests/schema/tests.py
index 41c1cd5120..4f3c2b361b 100644
--- a/tests/schema/tests.py
+++ b/tests/schema/tests.py
@@ -304,6 +304,24 @@ class SchemaTests(TransactionTestCase):
editor.alter_field(AuthorTextFieldWithIndex, old_field, new_field, strict=True)
self.assertForeignKeyExists(AuthorTextFieldWithIndex, 'text_field_id', 'schema_author')
+ @isolate_apps('schema')
+ def test_char_field_pk_to_auto_field(self):
+ class Foo(Model):
+ id = CharField(max_length=255, primary_key=True)
+
+ class Meta:
+ app_label = 'schema'
+
+ with connection.schema_editor() as editor:
+ editor.create_model(Foo)
+ self.isolated_local_models = [Foo]
+ old_field = Foo._meta.get_field('id')
+ new_field = AutoField(primary_key=True)
+ new_field.set_attributes_from_name('id')
+ new_field.model = Foo
+ with connection.schema_editor() as editor:
+ editor.alter_field(Foo, old_field, new_field, strict=True)
+
@skipUnlessDBFeature('supports_foreign_keys')
def test_fk_to_proxy(self):
"Creating a FK to a proxy model creates database constraints."