Opened 9 years ago

Closed 9 years ago

#23844 closed Cleanup/optimization (fixed)

Use topological sort for migration operation dependency resolution

Reported by: Patryk Zawadzki Owned by: nobody
Component: Migrations Version: dev
Severity: Normal Keywords:
Cc: info+coding@… Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

A fixed implementation is provided in https://github.com/django/django/pull/3546

The initial implementation was provided by vanschelven, accepted and commited as part of https://github.com/django/django/pull/3525. It however broke in Python 3 due to how __eq__ and __hash__ behave.

I opted not to provide a default implementation of deconstruct method to avoid arguments moving between args and kwargs depending on invocation (like the deconstruction of model fields it always produces the canonical form).

Change History (3)

comment:1 by Markus Holtermann, 9 years ago

Cc: info+coding@… added
Needs documentation: set
Patch needs improvement: set
Triage Stage: UnreviewedAccepted

comment:2 by Tim Graham, 9 years ago

Needs documentation: unset
Patch needs improvement: unset
Triage Stage: AcceptedReady for checkin

I left some cosmetic comments and Carl says it needs to be rebased to apply cleanly and commits squashed.

comment:3 by Tim Graham <timograham@…>, 9 years ago

Resolution: fixed
Status: newclosed

In 21e21c7bc2b8bf7ae127e2aa75048a60d05a6e0f:

Fixed #23844 -- Used topological sort for migration operation dependency resolution.

This removes the concept of equality between operations to guarantee
compatilibity with Python 3.

Python 3 requires equality to result in identical object hashes. It's
impossible to implement a unique hash that preserves equality as
operations such as field creation depend on being able to accept
arbitrary dicts that cannot be hashed reliably.

Thanks Klaas van Schelven for the original patch in
13d613f80011852404198dfafd1f09c0c0ea42e6.

Note: See TracTickets for help on using tickets.
Back to Top