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:59:35 -0400 |
| commit | 74bbef4ee0112144f302bb6509fd41a6b09ed63e (patch) | |
| tree | 3b09f6773a36640b4d24b02da14a9089000edc70 /django/db/models/sql | |
| parent | 66b834e73fd2809e5c7eccefc3b6a112ad129f59 (diff) | |
[2.0.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 b537eaea12..b205ff0281 100644 --- a/django/db/models/sql/compiler.py +++ b/django/db/models/sql/compiler.py @@ -160,7 +160,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 |
