Opened 17 years ago
Closed 17 years ago
#5321 closed (fixed)
PostgreSQL fails on a ValuesQuerySet which is ordered by a field not in the fields list
Reported by: | Chris Beaven | Owned by: | nobody |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | dev |
Severity: | Keywords: | qs-rf-fixed | |
Cc: | Triage Stage: | Accepted | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
This bug was found by accident while trying to provide a control test for #2939.
Basically, the failing test is:
Article.objects.values('pub_date').distinct()
Which fails on Postgres with for SELECT DISTINCT, ORDER BY expressions must appear in select list
Change History (4)
comment:1 by , 17 years ago
Keywords: | qs-rf added |
---|---|
Triage Stage: | Unreviewed → Accepted |
comment:2 by , 17 years ago
comment:3 by , 17 years ago
Keywords: | qs-rf-fixed added; qs-rf removed |
---|
comment:4 by , 17 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
(In [7477]) Merged the queryset-refactor branch into trunk.
This is a big internal change, but mostly backwards compatible with existing
code. Also adds a couple of new features.
Fixed #245, #1050, #1656, #1801, #2076, #2091, #2150, #2253, #2306, #2400, #2430, #2482, #2496, #2676, #2737, #2874, #2902, #2939, #3037, #3141, #3288, #3440, #3592, #3739, #4088, #4260, #4289, #4306, #4358, #4464, #4510, #4858, #5012, #5020, #5261, #5295, #5321, #5324, #5325, #5555, #5707, #5796, #5817, #5987, #6018, #6074, #6088, #6154, #6177, #6180, #6203, #6658
(In [6515]) queryset-refactor: Made sure the ordering columns in a distinct() query only
include the columns we are selecting on. This avoids some PostgreSQL problems
and leads to more efficient queries to boot. Refs #5321.