[Django] #28166: Model _state.db for an inherited object is not correctly populated

37 views
Skip to first unread message

Django

unread,
May 3, 2017, 6:12:53 AM5/3/17
to django-...@googlegroups.com
#28166: Model _state.db for an inherited object is not correctly populated
-----------------------------------------+------------------------
Reporter: wckao | Owner: nobody
Type: Uncategorized | Status: new
Component: Uncategorized | Version: 1.11
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 |
-----------------------------------------+------------------------
For the following models:

{{{
class ModelA(models.Model):
name = models.CharField(max_length=10)

class ModelB(ModelA):
is_active = models.BooleanField()
}}}

On shell:
{{{
b = ModelB.objects.create(name="test", is_active=True)
b.id = None
b.pk = None
b.save()
print(b._state.db, b.modela_ptr._state.db)
}}}

On 1.10, it shows **"default default"**,
but after upgrading from 1.10 to 1.11, it shows **"default None"**

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

Django

unread,
May 3, 2017, 6:14:51 AM5/3/17
to django-...@googlegroups.com
#28166: Model _state.db for an inherited object is not correctly populated to
parent object
-------------------------------+--------------------------------------

Reporter: wckao | Owner: nobody
Type: Uncategorized | Status: new
Component: Uncategorized | Version: 1.11
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
-------------------------------+--------------------------------------

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

Django

unread,
May 3, 2017, 7:57:01 AM5/3/17
to django-...@googlegroups.com
#28166: Model _state.db for an inherited object is not correctly populated to
parent object
-------------------------------------+-------------------------------------
Reporter: wckao | Owner: nobody
Type: Bug | Status: new
Component: Database layer | Version: 1.11
(models, ORM) |
Severity: Release blocker | 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 Tim Graham):

* type: Uncategorized => Bug
* component: Uncategorized => Database layer (models, ORM)
* severity: Normal => Release blocker
* stage: Unreviewed => Accepted


Comment:

Bisected to 38575b007a722d6af510ea46d46393a4cda9ca29.

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

Django

unread,
May 3, 2017, 9:56:33 AM5/3/17
to django-...@googlegroups.com
#28166: Model _state.db for an inherited object is not correctly populated to
parent object
-------------------------------------+-------------------------------------
Reporter: wckao | Owner: nobody

Type: Bug | Status: new
Component: Database layer | Version: 1.11
(models, ORM) |
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Simon Charette):

It should only be a matter of storing the result of `rel_model` in a
temporary variable to assign `_state.db = instance._state.db` to it before
returning in
[https://github.com/django/django/commit/38575b007a722d6af510ea46d46393a4cda9ca29
#diff-e0e6b7bbb34fe6e0bfae9aedede3405fR282 ForwardOneToOneDescriptor.
get_object()].

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

Django

unread,
May 3, 2017, 10:43:35 AM5/3/17
to django-...@googlegroups.com
#28166: Model _state.db for an inherited object is not correctly populated to
parent object
-------------------------------------+-------------------------------------
Reporter: wckao | Owner: nobody

Type: Bug | Status: new
Component: Database layer | Version: 1.11
(models, ORM) |
Severity: Release blocker | 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 Tim Graham):

* has_patch: 0 => 1


Comment:

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

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

Django

unread,
May 3, 2017, 12:30:45 PM5/3/17
to django-...@googlegroups.com
#28166: Model _state.db for an inherited object is not correctly populated to
parent object
-------------------------------------+-------------------------------------
Reporter: wckao | Owner: nobody
Type: Bug | Status: closed

Component: Database layer | Version: 1.11
(models, ORM) |
Severity: Release blocker | Resolution: fixed
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 Tim Graham <timograham@…>):

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


Comment:

In [changeset:"584e10c76edcd3a33765a52c5cde0096a3ce7dbc" 584e10c7]:
{{{
#!CommitTicketReference repository=""
revision="584e10c76edcd3a33765a52c5cde0096a3ce7dbc"
Fixed #28166 -- Fixed Model._state.db on MTI parent model after saving
child model.

Regression in 38575b007a722d6af510ea46d46393a4cda9ca29.
}}}

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

Django

unread,
May 3, 2017, 12:39:12 PM5/3/17
to django-...@googlegroups.com
#28166: Model _state.db for an inherited object is not correctly populated to
parent object
-------------------------------------+-------------------------------------
Reporter: wckao | Owner: nobody

Type: Bug | Status: closed
Component: Database layer | Version: 1.11
(models, ORM) |
Severity: Release blocker | Resolution: fixed
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Tim Graham <timograham@…>):

In [changeset:"f3217ab59696ea095a42c7fb4d98f21bb000ca8e" f3217ab5]:
{{{
#!CommitTicketReference repository=""
revision="f3217ab59696ea095a42c7fb4d98f21bb000ca8e"
[1.11.x] Fixed #28166 -- Fixed Model._state.db on MTI parent model after
saving child model.

Regression in 38575b007a722d6af510ea46d46393a4cda9ca29.

Backport of 584e10c76edcd3a33765a52c5cde0096a3ce7dbc from master
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/28166#comment:6>

Reply all
Reply to author
Forward
0 new messages