diff options
| author | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2020-01-04 20:49:11 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-01-04 20:49:11 +0100 |
| commit | 0f843fdd5b9b2f2307148465cd60f4e1b2befbb4 (patch) | |
| tree | 8a7bd17d7c5a9510301e793591037f4ab14ddec5 /django/db/models | |
| parent | 495d7a1ddf3c8c83d49f099ee3599afbc28306fe (diff) | |
Fixed #31136 -- Disabled grouping by aliases on QuerySet.values()/values_list().
Regression in fb3f034f1c63160c0ff13c609acd01c18be12f80.
Thanks Sigurd Ljødal for the report.
Diffstat (limited to 'django/db/models')
| -rw-r--r-- | django/db/models/sql/query.py | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/django/db/models/sql/query.py b/django/db/models/sql/query.py index fc423b6acf..f96a0a6e2d 100644 --- a/django/db/models/sql/query.py +++ b/django/db/models/sql/query.py @@ -2095,7 +2095,9 @@ class Query(BaseExpression): if self.group_by is True: self.add_fields((f.attname for f in self.model._meta.concrete_fields), False) - self.set_group_by() + # Disable GROUP BY aliases to avoid orphaning references to the + # SELECT clause which is about to be cleared. + self.set_group_by(allow_aliases=False) self.clear_select_fields() if fields: |
