#33932: Altering AutoFields with renaming a column crashes on PostgreSQL.
-------------------------------------+-------------------------------------
Reporter: BenoƮt Vinot Roseau | Owner: nobody
Technologies |
Type: Bug | Status: new
Component: Migrations | Version: 4.1
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Mariusz Felisiak):
Great!, I created a regression test inspired by your migrations:
{{#!diff
+ def test_autofield_to_o2o(self):
+ with connection.schema_editor() as editor:
+ editor.create_model(Author)
+ editor.create_model(Note)
+
+ # Rename the field.
+ old_field = Author._meta.get_field("id")
+ new_field = AutoField(primary_key=True)
+ new_field.set_attributes_from_name("note_ptr")
+ with connection.schema_editor() as editor:
+ editor.alter_field(Author, old_field, new_field, strict=True)
+ # Alter AutoField to OneToOneField.
+ new_field_o2o = OneToOneField(Note, CASCADE)
+ new_field_o2o.set_attributes_from_name("note_ptr")
+ with connection.schema_editor() as editor:
+ editor.alter_field(Author, new_field, new_field_o2o,
strict=True)
+ columns = self.column_classes(Author)
+ field_type, _ = columns["note_ptr_id"]
+ self.assertEqual(
+ field_type,
connection.features.introspected_field_types["IntegerField"]
+ )
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/33932#comment:6>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/01070182ab6216ca-b9e9ade0-e85e-4f62-8758-e27a70e2d69e-000000%40eu-central-1.amazonses.com.