summaryrefslogtreecommitdiff
path: root/django/db/models/sql/compiler.py
diff options
context:
space:
mode:
authorSimon Charette <charette.s@gmail.com>2022-11-05 12:41:56 -0400
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2022-11-07 11:36:05 +0100
commit041551d716b69ee7c81199eee86a2d10a72e15ab (patch)
tree2f76771cb42545f6ce2da513a35b8fb6fe679cfb /django/db/models/sql/compiler.py
parent967f8750ab63f9ca74ce63ada580ccc5b10b3f3b (diff)
downloaddjango-041551d716b69ee7c81199eee86a2d10a72e15ab.tar.gz
Fixed #31331 -- Switched MySQL to group by selected primary keys.
MySQL 5.7.15 supports group by functional dependences so there is no need to special case group by main table primary key anymore and special case the ONLY_FULL_GROUP_BY sql mode.
Diffstat (limited to 'django/db/models/sql/compiler.py')
-rw-r--r--django/db/models/sql/compiler.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/django/db/models/sql/compiler.py b/django/db/models/sql/compiler.py
index f3b2b3da41..b6574eab2e 100644
--- a/django/db/models/sql/compiler.py
+++ b/django/db/models/sql/compiler.py
@@ -235,7 +235,9 @@ class SQLCompiler:
expressions = [
expr
for expr in expressions
- if expr in pks or getattr(expr, "alias", None) not in aliases
+ if expr in pks
+ or expr in having
+ or getattr(expr, "alias", None) not in aliases
]
return expressions