[Django] #29751: Saving deserialized objects in custom migration fails in certain cases

6 views
Skip to first unread message

Django

unread,
Sep 12, 2018, 1:51:25 AM9/12/18
to django-...@googlegroups.com
#29751: Saving deserialized objects in custom migration fails in certain cases
-------------------------------------+-------------------------------------
Reporter: 0xKD | Owner: nobody
Type: Bug | Status: new
Component: Database | Version: 1.11
layer (models, ORM) | Keywords:
Severity: Normal | serialize,deserialize,migration
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 1
UI/UX: 0 |
-------------------------------------+-------------------------------------
Saving deserialised objects in custom migration fails in certain cases
(model has new fields added since) because `_get_model` used
[[https://github.com/django/django/blob/b9cf764be62e77b4777b3a75ec256f6209a57671/django/core/serializers/python.py#L91|here]]
uses the latest version of the model (rather than the migration-specific
model, which is derived using `apps.get_model` where `apps` is the first
argument passed to a custom migration function - which is passed to
`migrations.RunPython`)

Fix here would be to pass the `apps` received as first argument in a
custom migration via the `**options` in `deserialize()`

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

Django

unread,
Sep 12, 2018, 1:51:43 AM9/12/18
to django-...@googlegroups.com
#29751: Saving deserialized objects in custom migration fails in certain cases
-------------------------------------+-------------------------------------
Reporter: 0xKD | Owner: 0xKD
Type: Bug | Status: assigned
Component: Database layer | Version: 1.11
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage:
serialize,deserialize,migration | Unreviewed
Has patch: 0 | Needs documentation: 0

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

* status: new => assigned
* owner: nobody => 0xKD


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

Django

unread,
Sep 12, 2018, 2:57:42 AM9/12/18
to django-...@googlegroups.com
#29751: Saving deserialized objects in custom migration fails in certain cases
-------------------------------------+-------------------------------------
Reporter: 0xKD | Owner: 0xKD
Type: Bug | Status: assigned
Component: Migrations | Version: 1.11

Severity: Normal | Resolution:
Keywords: | Triage Stage:
serialize,deserialize,migration | Unreviewed
Has patch: 0 | Needs documentation: 0

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

* component: Database layer (models, ORM) => Migrations
* easy: 1 => 0


Comment:

At first glance this seems plausible.

@0xKD: you've assigned yourself. Can you add a failing test case that
reproduces the issue here?

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

Django

unread,
Sep 12, 2018, 12:54:14 PM9/12/18
to django-...@googlegroups.com
#29751: Saving deserialized objects in custom migration fails in certain cases
-------------------------------------+-------------------------------------
Reporter: 0xKD | Owner: 0xKD
Type: Bug | Status: closed
Component: Migrations | Version: 1.11
Severity: Normal | Resolution: duplicate

Keywords: | Triage Stage:
serialize,deserialize,migration | Unreviewed
Has patch: 0 | Needs documentation: 0

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

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


Comment:

I'd call this is a duplicate of #24778.

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

Reply all
Reply to author
Forward
0 new messages