Refs #33482 -- Fixed QuerySet selecting and filtering againts negated Exists() with empty queryset.

Regression in b7d1da5a62.
This commit is contained in:
Mariusz Felisiak 2022-02-07 20:34:21 +01:00 committed by GitHub
parent 25514b604a
commit 6f185a53a2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 1 deletions

View file

@ -1221,7 +1221,10 @@ class Exists(Subquery):
)
except EmptyResultSet:
if self.negated:
return '', ()
features = compiler.connection.features
if not features.supports_boolean_expr_in_select_clause:
return "1=1", ()
return compiler.compile(Value(True))
raise
if self.negated:
sql = 'NOT {}'.format(sql)