Opened 11 years ago
Closed 9 years ago
#21252 closed Bug (fixed)
Positional column numbers is not always correct for ORDER BY and GROUP BY
Reported by: | Michael Manfre | Owned by: | nobody |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | dev |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Accepted | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
"SELECT ... GROUP BY 1 ORDER BY 1" is very fragile and may not associate with the intended column if any columns are front loaded on to the select. Columns are front loaded by extra() and could be added by 3rd party database backends.
There are discussions of no longer front loading the extra() select columns. Assuming this change happens, the problem space would be reduced to just 3rd party backends, which would need some way to know that there are positional values in the query or would need an easier way of injecting columns in to the select without resorting to the simple front loading.
Change History (3)
comment:1 by , 11 years ago
Triage Stage: | Unreviewed → Accepted |
---|
comment:2 by , 9 years ago
It's unclear to me what needs to be done to resolve this ticket. Michael, could you say if this is still an issue and elaborate if so?
comment:3 by , 9 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
It seems Django doesn't anymore generate queries of the form ORDER BY 1. Thus, I think we can close this ticket. If there are indeed places where Django generates such queries (instead of the user explicitly asking for such queries), then please reopen.
I'll resolve as fixed due to the fact that we have removed DateQueryset.
I agree. Seems to be issue only in DateQueries, and hopefully that area will be improved soonish.