summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Charette <charette.s@gmail.com>2025-01-11 11:29:52 -0500
committerSarah Boyce <42296566+sarahboyce@users.noreply.github.com>2025-01-13 11:13:29 +0100
commit20eb4bca7de945d8858d1354a8c624406c0b90bd (patch)
tree26d56216db8ccf259cd87b036db9af1bcada1217
parentbfcb34076e3c0c04cb5080a37d93225444ac1b82 (diff)
Refs #373 -- Adjusted test allowing AutoField in composite primary keys.
This is not a properly supported feature yet and should be revisited by refs #35957.
-rw-r--r--tests/migrations/test_operations.py11
1 files changed, 7 insertions, 4 deletions
diff --git a/tests/migrations/test_operations.py b/tests/migrations/test_operations.py
index 2ca8da31f7..e92b1c4506 100644
--- a/tests/migrations/test_operations.py
+++ b/tests/migrations/test_operations.py
@@ -6562,6 +6562,9 @@ class OperationTests(OperationTestBase):
def test_composite_pk_operations(self):
app_label = "test_d8d90af6"
project_state = self.set_up_test_model(app_label)
+ operation_0 = migrations.AlterField(
+ "Pony", "id", models.IntegerField(primary_key=True)
+ )
operation_1 = migrations.AddField(
"Pony", "pk", models.CompositePrimaryKey("id", "pink")
)
@@ -6571,12 +6574,12 @@ class OperationTests(OperationTestBase):
# 1. Add field (pk).
new_state = project_state.clone()
- operation_1.state_forwards(app_label, new_state)
- with connection.schema_editor() as editor:
- operation_1.database_forwards(app_label, editor, project_state, new_state)
+ new_state = self.apply_operations(
+ app_label, new_state, [operation_0, operation_1]
+ )
self.assertColumnNotExists(table_name, "pk")
Pony = new_state.apps.get_model(app_label, "pony")
- obj_1 = Pony.objects.create(weight=1)
+ obj_1 = Pony.objects.create(id=1, weight=1)
msg = (
f"obj_1={obj_1}, "
f"obj_1.id={obj_1.id}, "