From 8fe233eccd3ece0cb33467bf942866590f97fdd2 Mon Sep 17 00:00:00 2001
From: John Bowen <jbowen7@gmail.com>
Date: Fri, 22 Nov 2019 12:43:03 +0000
Subject: [PATCH] Fixes #27914 -- Fixed serialization of nested classes
serialized by TypeSerializer.
---
django/db/migrations/serializer.py | 2 +-
tests/migrations/test_writer.py | 7 +++++++
2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/django/db/migrations/serializer.py b/django/db/migrations/serializer.py
index 7d22695..ead81c3 100644
a
|
b
|
class TypeSerializer(BaseSerializer):
|
269 | 269 | if module == builtins.__name__: |
270 | 270 | return self.value.__name__, set() |
271 | 271 | else: |
272 | | return "%s.%s" % (module, self.value.__name__), {"import %s" % module} |
| 272 | return "%s.%s" % (module, self.value.__qualname__), {"import %s" % module} |
273 | 273 | |
274 | 274 | |
275 | 275 | class UUIDSerializer(BaseSerializer): |
diff --git a/tests/migrations/test_writer.py b/tests/migrations/test_writer.py
index ca924f3..99c9cbf 100644
a
|
b
|
class WriterTests(SimpleTestCase):
|
293 | 293 | ("migrations.test_writer.IntEnum['B']", {'import migrations.test_writer'}) |
294 | 294 | ) |
295 | 295 | self.assertSerializedResultEqual( |
| 296 | self.NestedEnum, |
| 297 | ( |
| 298 | "migrations.test_writer.WriterTests.NestedEnum", |
| 299 | {'import migrations.test_writer'}, |
| 300 | ), |
| 301 | ) |
| 302 | self.assertSerializedResultEqual( |
296 | 303 | self.NestedEnum.A, |
297 | 304 | ( |
298 | 305 | "migrations.test_writer.WriterTests.NestedEnum['A']", |