#25492 - Altering a foreign key's structure and data in the same transaction.
(self)
| 1265 | |
| 1266 | @skipUnlessDBFeature("can_defer_constraint_checks", "can_rollback_ddl") |
| 1267 | def test_alter_fk_checks_deferred_constraints(self): |
| 1268 | """ |
| 1269 | #25492 - Altering a foreign key's structure and data in the same |
| 1270 | transaction. |
| 1271 | """ |
| 1272 | with connection.schema_editor() as editor: |
| 1273 | editor.create_model(Node) |
| 1274 | old_field = Node._meta.get_field("parent") |
| 1275 | new_field = ForeignKey(Node, CASCADE) |
| 1276 | new_field.set_attributes_from_name("parent") |
| 1277 | parent = Node.objects.create() |
| 1278 | with connection.schema_editor() as editor: |
| 1279 | # Update the parent FK to create a deferred constraint check. |
| 1280 | Node.objects.update(parent=parent) |
| 1281 | editor.alter_field(Node, old_field, new_field, strict=True) |
| 1282 | |
| 1283 | @isolate_apps("schema") |
| 1284 | def test_alter_null_with_default_value_deferred_constraints(self): |
nothing calls this directly
no test coverage detected