[Django] #24687: select_related field validation doesn't work for nested non-relation fields

183 views
Skip to first unread message

Django

unread,
Apr 22, 2015, 1:58:20 PM4/22/15
to django-...@googlegroups.com
#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.

Django

unread,
Apr 22, 2015, 1:58:50 PM4/22/15
to django-...@googlegroups.com
#24687: select_related field validation doesn't work for nested non-relation fields
-------------------------------------+-------------------------------------
Reporter: timgraham | Owner: nobody
Type: Bug | Status: new
Component: Database layer | Version: 1.8
(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 timgraham):

* Attachment "24687-test.diff" added.

Django

unread,
Apr 27, 2015, 1:47:52 PM4/27/15
to django-...@googlegroups.com
#24687: select_related field validation doesn't work for nested non-relation fields
-------------------------------------+-------------------------------------
Reporter: timgraham | Owner: nobody
Type: Bug | Status: new
Component: Database layer | Version: 1.8
(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 Naddiseo):

* cc: github@… (added)


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

Django

unread,
Oct 9, 2015, 9:27:05 PM10/9/15
to django-...@googlegroups.com
#24687: select_related field validation doesn't work for nested non-relation fields
-------------------------------------+-------------------------------------
Reporter: timgraham | Owner: timgraham
Type: Bug | Status: assigned

Component: Database layer | Version: 1.8
(models, ORM) |
Severity: Normal | 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 timgraham):

* status: new => assigned
* owner: nobody => timgraham
* has_patch: 0 => 1


Comment:

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

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

Django

unread,
Oct 9, 2015, 9:51:34 PM10/9/15
to django-...@googlegroups.com
#24687: select_related field validation doesn't work for nested non-relation fields
-------------------------------------+-------------------------------------
Reporter: timgraham | Owner: timgraham
Type: Bug | Status: assigned
Component: Database layer | Version: 1.8
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by timgraham):

* needs_better_patch: 0 => 1


Comment:

A GIS failure needs to be addressed.

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

Django

unread,
Oct 10, 2015, 8:52:30 AM10/10/15
to django-...@googlegroups.com
#24687: select_related field validation doesn't work for nested non-relation fields
-------------------------------------+-------------------------------------
Reporter: timgraham | Owner: timgraham
Type: Bug | Status: assigned
Component: Database layer | Version: 1.8
(models, ORM) |
Severity: Normal | 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 timgraham):

* needs_better_patch: 1 => 0


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

Django

unread,
Oct 10, 2015, 11:17:31 AM10/10/15
to django-...@googlegroups.com
#24687: select_related field validation doesn't work for nested non-relation fields
-------------------------------------+-------------------------------------
Reporter: timgraham | Owner: timgraham
Type: Bug | Status: assigned
Component: Database layer | Version: 1.8
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

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

* stage: Accepted => Ready for checkin


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

Django

unread,
Oct 10, 2015, 1:44:22 PM10/10/15
to django-...@googlegroups.com
#24687: select_related field validation doesn't work for nested non-relation fields
-------------------------------------+-------------------------------------
Reporter: timgraham | Owner: timgraham
Type: Bug | Status: closed

Component: Database layer | Version: 1.8
(models, ORM) |
Severity: Normal | Resolution: fixed

Keywords: | Triage Stage: Ready for
| checkin
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: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"67732a9b183d2e84c85147b04fdf9499f4395ac6" 67732a9]:
{{{
#!CommitTicketReference repository=""
revision="67732a9b183d2e84c85147b04fdf9499f4395ac6"
Fixed #24687 -- Added select_related() validation for nested non-
relational fields.

The removed test was added in the original select_related() validation
patch (45d4e43d2d25b902e3821b612209afa951a8bcb8), but there doesn't
seem to be any reason for it.

Thanks Claude Paroz for help and review.
}}}

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

Reply all
Reply to author
Forward
0 new messages