[Django] #29129: Child model updates parent model with empty fields making an extra query in multi-inheritance use case

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

[Django] #29129: Child model updates parent model with empty fields making an extra query in multi-inheritance use case

Django
#29129: Child model updates parent model with empty fields making an extra query in
multi-inheritance use case
-------------------------------------+-------------------------------------
               Reporter:  user0007   |          Owner:  nobody
                   Type:  Bug        |         Status:  new
              Component:  Database   |        Version:  2.0
  layer (models, ORM)                |
               Severity:  Normal     |       Keywords:
           Triage Stage:             |      Has patch:  0
  Unreviewed                         |
    Needs documentation:  0          |    Needs tests:  0
Patch needs improvement:  0          |  Easy pickings:  0
                  UI/UX:  0          |
-------------------------------------+-------------------------------------
 While creating a new model object (using multi-inheritance model =>
 `Child(Parent)`), Django does an extra update query setting parent model
 fields to empty values. This situation occurs *only* if we define a custom
 primary key in a parent model (eg. as an UUID field).

 An example *without* custom primary key (correct behavior):

 {{{
 class Parent(models.Model):
     title = models.TextField()

 class Child(Parent):
     body = models.TextField()


 >> Child.objects.create()

 1. INSERT INTO "app_parent" ("title") VALUES ('') RETURNING
 "app_parent"."id"
 2. INSERT INTO "app_child" ("parent_ptr_id", "body") VALUES (1, '')
 }}}

 An example *with* custom primary key (incorrect behavior):

 {{{
 class Parent(models.Model):
     id = models.UUIDField(
         primary_key=True,
         default=uuid.uuid4,
         editable=False
     )
     title = models.TextField()

 class Child(Parent):
     body = models.TextField()


 >> Child.objects.create()

 1. UPDATE "app_parent" SET "title" = '' WHERE "app_parent"."id" =
 'd750cfdd-ae7b-48a6-a2e0-d49e70e28686'::uuid
 2. INSERT INTO "app_parent" ("id", "title") VALUES ('d750cfdd-ae7b-
 48a6-a2e0-d49e70e28686'::uuid, '')
 3. INSERT INTO "app_child" ("parent_ptr_id", "body") VALUES ('d750cfdd-
 ae7b-48a6-a2e0-d49e70e28686'::uuid, '')
 }}}


 Python 3.6, PostgreSQL 9.6

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

--
You received this message because you are subscribed to the Google Groups "Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/051.810207368c7acc3ec882e1dde5aa4ccb%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [Django] #29129: Child model updates parent model with empty fields making an extra query in multi-inheritance when parent model has custom PK (was: Child model updates parent model with empty fields making an extra query in multi-inheritance use case)

Django
#29129: Child model updates parent model with empty fields making an extra query in
multi-inheritance when parent model has custom PK
-------------------------------------+-------------------------------------
     Reporter:  user0007             |                    Owner:  nobody
         Type:  Bug                  |                   Status:  new
    Component:  Database layer       |                  Version:  2.0
  (models, ORM)                      |
     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 Tim Graham):

 * stage:  Unreviewed => Accepted


Comment:

 That does look unexpected. Reproduced at
 cb7860ccedb199cb221c9e084b5104978b246356.

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

--
You received this message because you are subscribed to the Google Groups "Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/066.c7d12569faccb3dfc3086a95093d9409%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [Django] #29129: Child model updates parent model with empty fields making an extra query in multi-inheritance when parent model has custom PK

Django
In reply to this post by Django
#29129: Child model updates parent model with empty fields making an extra query in
multi-inheritance when parent model has custom PK
-------------------------------------+-------------------------------------
     Reporter:  user0007             |                    Owner:  Ashaba
                                     |  John
         Type:  Bug                  |                   Status:  assigned
    Component:  Database layer       |                  Version:  2.0
  (models, ORM)                      |
     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 Ashaba John):

 * owner:  nobody => Ashaba John
 * status:  new => assigned


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

--
You received this message because you are subscribed to the Google Groups "Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/066.ec97f2fc529a1b076177f98e08166f20%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [Django] #29129: Child model updates parent model with empty fields making an extra query in multi-inheritance when parent model has custom PK

Django
In reply to this post by Django
#29129: Child model updates parent model with empty fields making an extra query in
multi-inheritance when parent model has custom PK
-------------------------------------+-------------------------------------
     Reporter:  user0007             |                    Owner:  Ashaba
                                     |  John
         Type:  Bug                  |                   Status:  assigned
    Component:  Database layer       |                  Version:  2.0
  (models, ORM)                      |
     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
-------------------------------------+-------------------------------------

Comment (by user0007):

 Replying to [comment:2 Ashaba John]:
 Any chance to see fix for that in 2.1 release?

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

--
You received this message because you are subscribed to the Google Groups "Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/066.957191f3104016dd19b4a18206c851d5%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [Django] #29129: Child model updates parent model with empty fields making an extra query in multi-inheritance when parent model has custom PK

Django
In reply to this post by Django
#29129: Child model updates parent model with empty fields making an extra query in
multi-inheritance when parent model has custom PK
-------------------------------------+-------------------------------------
     Reporter:  user0007             |                    Owner:  Ashaba
                                     |  John
         Type:  Bug                  |                   Status:  assigned
    Component:  Database layer       |                  Version:  2.0
  (models, ORM)                      |
     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
-------------------------------------+-------------------------------------

Comment (by Ashaba John):

 Replying to [comment:3 user0007]:
 > Replying to [comment:2 Ashaba John]:
 > Any chance to see fix for that in 2.1 release?
 Hey,

 Sorry for the delayed implementation. Will work on it and we should have
 it in the 2.1 release. Thanks

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

--
You received this message because you are subscribed to the Google Groups "Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/066.9d5b2e66975e122cd8c06254a2b08095%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [Django] #29129: Child model updates parent model with empty fields making an extra query in multi-inheritance when parent model has custom PK

Django
In reply to this post by Django
#29129: Child model updates parent model with empty fields making an extra query in
multi-inheritance when parent model has custom PK
-------------------------------------+-------------------------------------
     Reporter:  user0007             |                    Owner:  (none)
         Type:  Bug                  |                   Status:  new
    Component:  Database layer       |                  Version:  2.0
  (models, ORM)                      |
     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 Ashaba John):

 * owner:  Ashaba John => (none)
 * status:  assigned => new


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

--
You received this message because you are subscribed to the Google Groups "Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/066.1a9aeb950cbda350d5564110e8515f8e%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.