#24687: select_related field validation doesn't work for nested non-relation 
fields
-------------------------------------+-------------------------------------
               Reporter:  timgraham  |          Owner:  nobody
                   Type:  Bug        |         Status:  new
              Component:  Database   |        Version:  1.8
  layer (models, ORM)                |
               Severity:  Normal     |       Keywords:
           Triage Stage:  Accepted   |      Has patch:  0
    Needs documentation:  0          |    Needs tests:  0
Patch needs improvement:  0          |  Easy pickings:  0
                  UI/UX:  0          |
-------------------------------------+-------------------------------------
 The validation added in #10414 only occurs if the field is on the
 immediate model, or if it's invalid:

 {{{#!python

 >>> Person.objects.select_related('foo')
 django.core.exceptions.FieldError: Invalid field name(s) given in
 select_related: 'foo'. Choices are: hometown
 >>> Person.objects.select_related('hometown__foo')
 django.core.exceptions.FieldError: Invalid field name(s) given in
 select_related: 'foo'. Choices are: mayor
 >>> Person.objects.select_related('hometown__name')
 # query = select ... blah
 [ Person object ...]
 >>> Person.objects.select_related('name')
 django.core.exceptions.FieldError: Non-relational field given in
 select_related: 'name'. Choices are: hometown

 }}}

 Notice how it will happily accept the third one.  Failing test attached.

--
Ticket URL: <https://code.djangoproject.com/ticket/24687>
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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/052.62bd7d8f44065563aa06c85606d504cb%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to