(self)
| 642 | @isolate_apps("schema") |
| 643 | @skipUnlessDBFeature("supports_foreign_keys", "can_introspect_foreign_keys") |
| 644 | def test_create_model_db_on_delete(self): |
| 645 | class Parent(Model): |
| 646 | class Meta: |
| 647 | app_label = "schema" |
| 648 | |
| 649 | class Child(Model): |
| 650 | parent_fk = ForeignKey(Parent, DB_SET_NULL, null=True) |
| 651 | |
| 652 | class Meta: |
| 653 | app_label = "schema" |
| 654 | |
| 655 | with connection.schema_editor() as editor: |
| 656 | editor.create_model(Parent) |
| 657 | with CaptureQueriesContext(connection) as ctx: |
| 658 | with connection.schema_editor() as editor: |
| 659 | editor.create_model(Child) |
| 660 | |
| 661 | self.assertForeignKeyNotExists(Child, "parent_id", "schema_parent") |
| 662 | self.assertIs( |
| 663 | any("ON DELETE" in query["sql"] for query in ctx.captured_queries), True |
| 664 | ) |
| 665 | |
| 666 | @isolate_apps("schema") |
| 667 | def test_no_db_constraint_added_during_primary_key_change(self): |
nothing calls this directly
no test coverage detected