diff options
| author | Tim Graham <timograham@gmail.com> | 2014-10-23 12:24:34 -0400 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2014-10-23 12:24:34 -0400 |
| commit | 92269b7b53c9f69dd28e119c40b6bf32f96f7bd3 (patch) | |
| tree | ab545a6b1cb64ba122ac6e44ec6bcd6651a05fd6 /tests | |
| parent | 2d75515a4c4fe726e26ebb1a2d2acbc9d047cba6 (diff) | |
Fixed #23702 -- Fixed adding an explicit id field on SQLite.
Thanks gavinwahl for the report.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/schema/tests.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/schema/tests.py b/tests/schema/tests.py index 2042f00bcd..ef3d693afc 100644 --- a/tests/schema/tests.py +++ b/tests/schema/tests.py @@ -490,6 +490,25 @@ class SchemaTests(TransactionTestCase): else: self.fail("No FK constraint for author_id found") + def test_alter_implicit_id_to_explict(self): + """ + Should be able to convert an implicit "id" field to an explicit "id" + primary key field. + """ + with connection.schema_editor() as editor: + editor.create_model(Author) + + new_field = IntegerField(primary_key=True) + new_field.set_attributes_from_name("id") + new_field.model = Author + with connection.schema_editor() as editor: + editor.alter_field( + Author, + Author._meta.get_field_by_name("id")[0], + new_field, + strict=True, + ) + def test_rename(self): """ Tests simple altering of fields |
