diff options
| author | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2019-08-01 11:20:56 +0200 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2019-08-01 12:06:32 +0200 |
| commit | ff111ea5e39cf774b3cd4237790d2bffd2826fb0 (patch) | |
| tree | bb2b19e351a1d8dafa0e8bc7ac6d0519863416f6 /tests | |
| parent | e4684220af058789a9d2673a3503d2f88d8aa94a (diff) | |
Refs #30664 -- Fixed migrations crash when altering AutoField/BigAutoField with quoted db_column on PostgreSQL.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/schema/tests.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/schema/tests.py b/tests/schema/tests.py index 287ef200da..a765528d50 100644 --- a/tests/schema/tests.py +++ b/tests/schema/tests.py @@ -636,6 +636,26 @@ class SchemaTests(TransactionTestCase): with connection.schema_editor() as editor: editor.alter_field(Author, old_field, new_field, strict=True) + @isolate_apps('schema') + def test_alter_auto_field_quoted_db_column(self): + class Foo(Model): + id = AutoField(primary_key=True, db_column='"quoted_id"') + + 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 = BigAutoField(primary_key=True) + new_field.model = Foo + new_field.db_column = '"quoted_id"' + new_field.set_attributes_from_name('id') + with connection.schema_editor() as editor: + editor.alter_field(Foo, old_field, new_field, strict=True) + Foo.objects.create() + def test_alter_not_unique_field_to_primary_key(self): # Create the table. with connection.schema_editor() as editor: |
