Ticket #27914: 0001-Fixes-27914-Fixed-serialization-of-nested-classes-se.patch

File 0001-Fixes-27914-Fixed-serialization-of-nested-classes-se.patch, 1.7 KB (added by John Bowen, 5 years ago)

PR: https://github.com/django/django/pull/12125

  • django/db/migrations/serializer.py

    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):  
    269269            if module == builtins.__name__:
    270270                return self.value.__name__, set()
    271271            else:
    272                 return "%s.%s" % (module, self.value.__name__), {"import %s" % module}
     272                return "%s.%s" % (module, self.value.__qualname__), {"import %s" % module}
    273273
    274274
    275275class UUIDSerializer(BaseSerializer):
  • tests/migrations/test_writer.py

    diff --git a/tests/migrations/test_writer.py b/tests/migrations/test_writer.py
    index ca924f3..99c9cbf 100644
    a b class WriterTests(SimpleTestCase):  
    293293            ("migrations.test_writer.IntEnum['B']", {'import migrations.test_writer'})
    294294        )
    295295        self.assertSerializedResultEqual(
     296            self.NestedEnum,
     297            (
     298                "migrations.test_writer.WriterTests.NestedEnum",
     299                {'import migrations.test_writer'},
     300            ),
     301        )
     302        self.assertSerializedResultEqual(
    296303            self.NestedEnum.A,
    297304            (
    298305                "migrations.test_writer.WriterTests.NestedEnum['A']",
Back to Top