#33091: A FieldError should be raised when trying to update MTI inherited field
with F reference to child field
-------------------------------------+-------------------------------------
     Reporter:  Shai Berger          |                    Owner:  Abhijith
         Type:                       |  Ganesh
  Cleanup/optimization               |                   Status:  assigned
    Component:  Database layer       |                  Version:  dev
  (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 Shai Berger):

 Replying to [comment:8 Bhuvnesh]:
 > I think there is no direct way to get child field from opts of parent
 model in inheritance.

 That makes sense

 > For the testcase provided by shai the value of field is None at
 
[https://github.com/django/django/blob/9da2210f121085e998dc7cedb783bc4568390b92/django/db/models/sql/query.py#L1631
 this part] ,throwing different field error
 
[https://github.com/django/django/blob/9da2210f121085e998dc7cedb783bc4568390b92/django/db/models/sql/query.py#L1714
 here.] Is it the expected behaviour?

 No, that's the bug...


 > or we are supposed to get the child field and later raise field error
 {{{Joined field references are not permitted in this query.}}}

 Yes, basically. Or, putting it another way (given your input): The
 {{{update()}}} logic uses the parent model {{{opts}}}, because the fields
 to be updated are all from that model; but then it uses the parent model
 to resolve all references, and that is wrong if there are expressions
 referencing the child model. Or, more succinctly: The move to the parent
 model is too early.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/33091#comment:9>
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 django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/01070184fd38436c-9130633a-ab46-4e00-a6ca-b3f26d3dc9ee-000000%40eu-central-1.amazonses.com.

Reply via email to