(self)
| 1976 | self.assertEqual(counts, {"fks": expected_fks, "uniques": 1, "indexes": 0}) |
| 1977 | |
| 1978 | def test_autofield_to_o2o(self): |
| 1979 | with connection.schema_editor() as editor: |
| 1980 | editor.create_model(Author) |
| 1981 | editor.create_model(Note) |
| 1982 | |
| 1983 | # Rename the field. |
| 1984 | old_field = Author._meta.get_field("id") |
| 1985 | new_field = AutoField(primary_key=True) |
| 1986 | new_field.set_attributes_from_name("note_ptr") |
| 1987 | new_field.model = Author |
| 1988 | |
| 1989 | with connection.schema_editor() as editor: |
| 1990 | editor.alter_field(Author, old_field, new_field, strict=True) |
| 1991 | # Alter AutoField to OneToOneField. |
| 1992 | new_field_o2o = OneToOneField(Note, CASCADE) |
| 1993 | new_field_o2o.set_attributes_from_name("note_ptr") |
| 1994 | new_field_o2o.model = Author |
| 1995 | |
| 1996 | with connection.schema_editor() as editor: |
| 1997 | editor.alter_field(Author, new_field, new_field_o2o, strict=True) |
| 1998 | columns = self.column_classes(Author) |
| 1999 | field_type, _ = columns["note_ptr_id"] |
| 2000 | self.assertEqual( |
| 2001 | field_type, connection.features.introspected_field_types["BigIntegerField"] |
| 2002 | ) |
| 2003 | |
| 2004 | def test_alter_field_fk_keeps_index(self): |
| 2005 | with connection.schema_editor() as editor: |
nothing calls this directly
no test coverage detected