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:19 -0400 |
| commit | 4ab1f559e8d1264bcb20bb497988973194f5d8f2 (patch) | |
| tree | 521b3d654cca562b48406bb6b7cc04fa29076c07 /django | |
| parent | cd242d185bda9269913d4d101a7f704204ec907d (diff) | |
Fixed #29416 -- Removed unnecesary subquery from GROUP BY clause on MySQL when using a RawSQL annotation.
Regression in 1d070d027c218285b66c0bde8079034b33a87f11.
Diffstat (limited to 'django')
| -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 |
