Opened 9 years ago
Closed 9 years ago
#26648 closed Cleanup/optimization (fixed)
Add a system check for invalid related_query_names containing underscores
| Reported by: | Michal Petrucha | Owned by: | nobody |
|---|---|---|---|
| Component: | Core (System checks) | Version: | dev |
| Severity: | Normal | Keywords: | |
| Cc: | Triage Stage: | Ready for checkin | |
| Has patch: | yes | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
This came up on django-users@ the other week: https://groups.google.com/d/msg/django-users/vR6eR1l3AaY/Zo-H1nFtNwAJ
I think there should be a check for related_query_name to ensure it does not end with an underscore, or contain __ – in either case, it would be impossible to actually use it in a query.
I'll open a WIP PR in a moment, but when I implemented this check, it turned out that there's actually a test case already which treats related_name='_' (without an explicit related_query_name) as valid. Is that something we want to support?
Change History (5)
comment:1 by , 9 years ago
comment:2 by , 9 years ago
| Triage Stage: | Unreviewed → Accepted |
|---|---|
| Type: | Uncategorized → Cleanup/optimization |
I'll open a WIP PR in a moment, but when I implemented this check, it turned out that there's actually a test case already which treats related_name='_' (without an explicit related_query_name) as valid. Is that something we want to support?
No as it generates an unusable related_query_name.
comment:3 by , 9 years ago
| Has patch: | set |
|---|
comment:4 by , 9 years ago
| Summary: | related_query_name is not checked for correctness → Add a system check for invalid related_query_names containing underscores |
|---|---|
| Triage Stage: | Accepted → Ready for checkin |
PR as promised: https://github.com/django/django/pull/6640