1
0
mirror of https://github.com/django/django.git synced 2025-10-24 14:16:09 +00:00

Fixed #373 -- Added CompositePrimaryKey.

Thanks Lily Foote and Simon Charette for reviews and mentoring
this Google Summer of Code 2024 project.

Co-authored-by: Simon Charette <charette.s@gmail.com>
Co-authored-by: Lily Foote <code@lilyf.org>
This commit is contained in:
Bendeguz Csirmaz
2024-04-07 10:32:16 +08:00
committed by Sarah Boyce
parent 86661f2449
commit 978aae4334
43 changed files with 3078 additions and 29 deletions

View File

@@ -1138,3 +1138,22 @@ class WriterTests(SimpleTestCase):
ValueError, "'TestModel1' must inherit from 'BaseSerializer'."
):
MigrationWriter.register_serializer(complex, TestModel1)
def test_composite_pk_import(self):
migration = type(
"Migration",
(migrations.Migration,),
{
"operations": [
migrations.AddField(
"foo",
"bar",
models.CompositePrimaryKey("foo_id", "bar_id"),
),
],
},
)
writer = MigrationWriter(migration)
output = writer.as_string()
self.assertEqual(output.count("import"), 1)
self.assertIn("from django.db import migrations, models", output)