diff options
| author | David Sanders <shang.xiao.sanders@gmail.com> | 2023-11-13 00:45:52 +1100 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2023-11-13 12:01:40 +0100 |
| commit | b863c5ffde0bafa5eaa9f262103eaeb71877787c (patch) | |
| tree | 3e0930b96daeddee486a2f011fd4598db3fa7e6b /django/db/models/sql/compiler.py | |
| parent | 1b56b24f81a2e64b4bd3059abad9b6fd0c801c66 (diff) | |
Fixed #34967 -- Fixed queryset crash when grouping by constants on SQLite < 3.39.
On SQLite < 3.39, this forces a GROUP BY clause with a HAVING clause
when no grouping is specified.
Co-authored-by: Simon Charette <charette.s@gmail.com>
Diffstat (limited to 'django/db/models/sql/compiler.py')
| -rw-r--r-- | django/db/models/sql/compiler.py | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/django/db/models/sql/compiler.py b/django/db/models/sql/compiler.py index b28dc925ba..7cec040cee 100644 --- a/django/db/models/sql/compiler.py +++ b/django/db/models/sql/compiler.py @@ -877,6 +877,8 @@ class SQLCompiler: if self._meta_ordering: order_by = None if having: + if not grouping: + result.extend(self.connection.ops.force_group_by()) result.append("HAVING %s" % having) params.extend(h_params) |
