summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
authorDavid Wobrock <david.wobrock@gmail.com>2021-12-19 11:22:30 +0100
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2021-12-21 06:17:04 +0100
commit72b23c04d806adc8522fa9d10132e5c1d1011d5e (patch)
tree78c3a5b9b7f98638b1138d9556b2d689e040e15f /django
parent03cadb912c78b769d6bf4a943a2a35fc1d952960 (diff)
Fixed #33374 -- Fixed ExpressionWrapper annotations with full queryset.
Diffstat (limited to 'django')
-rw-r--r--django/db/models/fields/__init__.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/django/db/models/fields/__init__.py b/django/db/models/fields/__init__.py
index 0e72a09e59..f30b523346 100644
--- a/django/db/models/fields/__init__.py
+++ b/django/db/models/fields/__init__.py
@@ -994,6 +994,15 @@ class BooleanField(Field):
defaults = {'form_class': form_class, 'required': False}
return super().formfield(**{**defaults, **kwargs})
+ def select_format(self, compiler, sql, params):
+ sql, params = super().select_format(compiler, sql, params)
+ # Filters that match everything are handled as empty strings in the
+ # WHERE clause, but in SELECT or GROUP BY list they must use a
+ # predicate that's always True.
+ if sql == '':
+ sql = '1'
+ return sql, params
+
class CharField(Field):
description = _("String (up to %(max_length)s)")