[Django] #24537: Migration autodetector not detecting RenameModel if foreign keys are defined before sibling fields

23 views
Skip to first unread message

Django

unread,
Mar 25, 2015, 8:42:58 AM3/25/15
to django-...@googlegroups.com
#24537: Migration autodetector not detecting RenameModel if foreign keys are
defined before sibling fields
----------------------------+-------------------------
Reporter: rapilabs | Owner: nobody
Type: Bug | Status: new
Component: Migrations | Version: master
Severity: Normal | Keywords: RenameModel
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
----------------------------+-------------------------
(This may be related to #22931 as there was some discussion about failure
to detect model renaming there, although that ticket focused more on
exceptions being raised.)

Django Migrations seems to generate model migrations with foreign keys
placed last in a CreateModel migration, regardless of where they are
defined in the model. This can affect later model renames as the
autodetector fails to recognise that the model is the same; the newly
generated model state will have the same order as the model.

I've created a test case to confirm that the autodetector won't detect a
rename if the foreign keys are in a different order:
https://github.com/rapilabs/django/blob/master/tests/migrations/test_autodetector.py#L660

--
Ticket URL: <https://code.djangoproject.com/ticket/24537>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Mar 26, 2015, 8:56:17 AM3/26/15
to django-...@googlegroups.com
#24537: Migration autodetector not detecting RenameModel if foreign keys are
defined before sibling fields
-----------------------------+------------------------------------

Reporter: rapilabs | Owner: nobody
Type: Bug | Status: new
Component: Migrations | Version: master
Severity: Normal | Resolution:
Keywords: RenameModel | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-----------------------------+------------------------------------
Changes (by timgraham):

* needs_better_patch: => 0
* needs_docs: => 0
* needs_tests: => 0
* stage: Unreviewed => Accepted


--
Ticket URL: <https://code.djangoproject.com/ticket/24537#comment:1>

Django

unread,
Mar 28, 2015, 1:58:18 PM3/28/15
to django-...@googlegroups.com
#24537: Migration autodetector not detecting RenameModel if foreign keys are
defined before sibling fields
-----------------------------+------------------------------------
Reporter: rapilabs | Owner: MarkusH
Type: Bug | Status: assigned
Component: Migrations | Version: master

Severity: Normal | Resolution:
Keywords: RenameModel | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-----------------------------+------------------------------------
Changes (by MarkusH):

* status: new => assigned
* owner: nobody => MarkusH


--
Ticket URL: <https://code.djangoproject.com/ticket/24537#comment:2>

Django

unread,
Mar 28, 2015, 2:01:02 PM3/28/15
to django-...@googlegroups.com
#24537: Migration autodetector not detecting RenameModel if foreign keys are
defined before sibling fields
-----------------------------+------------------------------------
Reporter: rapilabs | Owner: MarkusH
Type: Bug | Status: assigned
Component: Migrations | Version: master

Severity: Normal | Resolution:
Keywords: RenameModel | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-----------------------------+------------------------------------
Changes (by MarkusH):

* has_patch: 0 => 1


Comment:

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

--
Ticket URL: <https://code.djangoproject.com/ticket/24537#comment:3>

Django

unread,
Mar 28, 2015, 3:54:30 PM3/28/15
to django-...@googlegroups.com
#24537: Migration autodetector not detecting RenameModel if foreign keys are
defined before sibling fields
-----------------------------+------------------------------------
Reporter: rapilabs | Owner: MarkusH
Type: Bug | Status: closed
Component: Migrations | Version: master
Severity: Normal | Resolution: fixed

Keywords: RenameModel | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-----------------------------+------------------------------------
Changes (by Markus Holtermann <info@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"c7ec3c07e78e288a48e87b979dbd12e1fa44fe66" c7ec3c0]:
{{{
#!CommitTicketReference repository=""
revision="c7ec3c07e78e288a48e87b979dbd12e1fa44fe66"
Fixed #24537 -- Ignored field order in RenameModel detection

Thanks to David Sanders for the report and test and Simon Charette for
the review.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/24537#comment:4>

Reply all
Reply to author
Forward
0 new messages