diff options
| author | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2018-05-28 00:25:19 +0200 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2018-05-27 18:25:42 -0400 |
| commit | b6e48f514ebe4e31b76e1750e043d4f296e645dc (patch) | |
| tree | 2270b406b7232240ca38779bf9ec1af3969092c2 /django/db/models/sql | |
| parent | 158e7804e780aa4dd227847856d14cf3214c2d67 (diff) | |
[2.1.x] Fixed #29416 -- Removed unnecesary subquery from GROUP BY clause on MySQL when using a RawSQL annotation.
Regression in 1d070d027c218285b66c0bde8079034b33a87f11.
Backport of 4ab1f559e8d1264bcb20bb497988973194f5d8f2 from master
Diffstat (limited to 'django/db/models/sql')
| -rw-r--r-- | django/db/models/sql/compiler.py | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/django/db/models/sql/compiler.py b/django/db/models/sql/compiler.py index f5222f21be..8b0fd1da46 100644 --- a/django/db/models/sql/compiler.py +++ b/django/db/models/sql/compiler.py @@ -157,7 +157,9 @@ class SQLCompiler: } expressions = [pk] + [ expr for expr in expressions - if expr in having or getattr(expr, 'alias', None) not in pk_aliases + if expr in having or ( + getattr(expr, 'alias', None) is not None and expr.alias not in pk_aliases + ) ] elif self.connection.features.allows_group_by_selected_pks: # Filter out all expressions associated with a table's primary key |
