Opened 10 years ago
Closed 9 years ago
#24687 closed Bug (fixed)
select_related field validation doesn't work for nested non-relation fields
Description ¶
The validation added in #10414 only occurs if the field is on the immediate model, or if it's invalid:
>>> 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.
Change History (7)
by , 10 years ago
Attachment: | 24687-test.diff added |
---|
comment:1 by , 10 years ago
Cc: | added |
---|
comment:2 by , 9 years ago
Has patch: | set |
---|---|
Owner: | changed from | to
Status: | new → assigned |
comment:4 by , 9 years ago
Patch needs improvement: | unset |
---|
comment:5 by , 9 years ago
Triage Stage: | Accepted → Ready for checkin |
---|
Note:
See TracTickets
for help on using tickets.
PR