[Django] #32262: squashmigrations does not unset model options when optimizing CreateModel and AlterModelOptions

14 views
Skip to first unread message

Django

unread,
Dec 12, 2020, 12:09:51 AM12/12/20
to django-...@googlegroups.com
#32262: squashmigrations does not unset model options when optimizing CreateModel
and AlterModelOptions
--------------------------------------------+------------------------
Reporter: InvalidInterrupt | Owner: nobody
Type: Bug | Status: new
Component: Migrations | Version: 2.2
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
--------------------------------------------+------------------------
When an operation resembling `AlterModelOptions(name="test_model",
options={})` is squashed into the corresponding `CreateModel` operation,
model options are not cleared on the resulting new `CreateModel` operation
object.

`CreateModel.reduce()` sets the new options as `options={**self.options,
**operation.options}` in this case
(`django/db/migrations/operations/models.py` line 144 on commit
`991dce4f`), with no logic to remove options not found in
`operation.options` as is found in `AlterModelOptions.state_forwards()`.

I believe this issue still exists on the master branch based on my reading
of the code, but I've only tested against 2.2.

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

Django

unread,
Dec 12, 2020, 12:10:07 AM12/12/20
to django-...@googlegroups.com
#32262: squashmigrations does not unset model options when optimizing CreateModel
and AlterModelOptions
----------------------------------+--------------------------------------

Reporter: InvalidInterrupt | Owner: nobody
Type: Bug | Status: new
Component: Migrations | Version: 2.2
Severity: Normal | Resolution:

Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
----------------------------------+--------------------------------------
Changes (by InvalidInterrupt):

* cc: InvalidInterrupt (added)


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

Django

unread,
Dec 12, 2020, 12:25:10 PM12/12/20
to django-...@googlegroups.com
#32262: squashmigrations does not unset model options when optimizing CreateModel
and AlterModelOptions
----------------------------------+------------------------------------

Reporter: InvalidInterrupt | Owner: nobody
Type: Bug | Status: new
Component: Migrations | Version: 2.2
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
----------------------------------+------------------------------------
Changes (by Simon Charette):

* stage: Unreviewed => Accepted


Comment:

Makes sense, I guess we should take `AlterModelOptions.ALTER_OPTION_KEYS`
in consideration here like `AlterModelOptions.state_forwards` does

https://github.com/django/django/blob/991dce4fc5b656e04af08a595181bd576f2bd857/django/db/migrations/operations/models.py#L675-L677

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

Django

unread,
Dec 17, 2020, 4:35:01 PM12/17/20
to django-...@googlegroups.com
#32262: squashmigrations does not unset model options when optimizing CreateModel
and AlterModelOptions
-------------------------------------+-------------------------------------
Reporter: InvalidInterrupt | Owner: Hasan
| Ramezani
Type: Bug | Status: assigned
Component: Migrations | Version: 2.2

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Hasan Ramezani):

* owner: nobody => Hasan Ramezani
* status: new => assigned
* has_patch: 0 => 1


Comment:

[https://github.com/django/django/pull/13786 PR]

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

Django

unread,
Dec 18, 2020, 12:59:55 AM12/18/20
to django-...@googlegroups.com
#32262: squashmigrations does not unset model options when optimizing CreateModel
and AlterModelOptions
-------------------------------------+-------------------------------------
Reporter: InvalidInterrupt | Owner: Hasan
| Ramezani
Type: Bug | Status: assigned
Component: Migrations | Version: 2.2
Severity: Normal | Resolution:
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* stage: Accepted => Ready for checkin


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

Django

unread,
Dec 18, 2020, 1:34:27 AM12/18/20
to django-...@googlegroups.com
#32262: squashmigrations does not unset model options when optimizing CreateModel
and AlterModelOptions
-------------------------------------+-------------------------------------
Reporter: InvalidInterrupt | Owner: Hasan
| Ramezani
Type: Bug | Status: closed
Component: Migrations | Version: 2.2
Severity: Normal | Resolution: fixed

Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak <felisiak.mariusz@…>):

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


Comment:

In [changeset:"8d582bf51058e3a8094a58f624c81bd95b6edfb1" 8d582bf]:
{{{
#!CommitTicketReference repository=""
revision="8d582bf51058e3a8094a58f624c81bd95b6edfb1"
Fixed #32262 -- Fixed migration optimization for model creation and Meta
options removal.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/32262#comment:5>

Reply all
Reply to author
Forward
0 new messages