[#26151] Refactor MigrationWriter.serialize() to use a factory pattern

54 views
Skip to first unread message

Markus Holtermann

unread,
Jan 29, 2016, 8:06:46 AM1/29/16
to Django developers (Contributions to Django itself)
Hi all,


This pull request suggests to rewrite the serialization in the MigrationWriter to dedicated classes which are then used by a factory function. The reasoning behind this is to reduce the complexity of the current serialize() function (according to the reporter McCabe Cyclomatic Complexity of 50).

The benefit that comes with the new approach -- yet not implemented and would be part of a separate issue -- is a dynamic way to introduce new serialization options for data types the current MigrationWriter does not support. While neither Simon nor Marten nor I could think of any such case, we'd like to get other peoples input.

In case we don't come up with cases where the current MigrationWriter fails, the discussion should be made if the added overhead is worth it. While I find the new code easier to grasp if I'd see it the first time, I'm happy to stick to the current implementation.

Cheers,

/Markus

Tim Graham

unread,
Jan 29, 2016, 8:29:35 AM1/29/16
to Django developers (Contributions to Django itself)
I doubt that serialization support is "feature complete", given some recent history. I guess it would be nice to have the hook so that users don't have to wait for the next release of Django.

Django 1.8.1: Added support for serializing datetime.timedelta objects.
Django 1.9: Added support for serialization of functools.partial and LazyObject instances.
Django 1.10: Added support for serialization of enum.Enum objects.
Reply all
Reply to author
Forward
0 new messages