mirror of
https://github.com/django/django.git
synced 2025-10-27 15:46:10 +00:00
Fixed #21961 -- Added support for database-level delete options for ForeignKey.
Thanks Simon Charette for pair programming. Co-authored-by: Nick Stefan <NickStefan12@gmail.com> Co-authored-by: Akash Kumar Sen <71623442+Akash-Kumar-Sen@users.noreply.github.com> Co-authored-by: Simon Charette <charette.s@gmail.com>
This commit is contained in:
@@ -971,6 +971,23 @@ class WriterTests(SimpleTestCase):
|
||||
("('models.Model', {'from django.db import models'})", set()),
|
||||
)
|
||||
|
||||
def test_database_on_delete_serializer_value(self):
|
||||
db_level_on_delete_options = [
|
||||
models.DB_CASCADE,
|
||||
models.DB_SET_DEFAULT,
|
||||
models.DB_SET_NULL,
|
||||
]
|
||||
for option in db_level_on_delete_options:
|
||||
self.assertSerializedEqual(option)
|
||||
self.assertSerializedResultEqual(
|
||||
MigrationWriter.serialize(option),
|
||||
(
|
||||
f"('django.db.models.deletion.{option.__name__}', "
|
||||
"{'import django.db.models.deletion'})",
|
||||
set(),
|
||||
),
|
||||
)
|
||||
|
||||
def test_simple_migration(self):
|
||||
"""
|
||||
Tests serializing a simple migration.
|
||||
|
||||
Reference in New Issue
Block a user