mirror of
https://github.com/django/django.git
synced 2025-08-22 11:34:33 +00:00
Fixed #33895 -- Fixed Case() crash with filters that match everything in When().
Thanks shukryzablah for the report.
This commit is contained in:
parent
63884829ac
commit
036bb2b74a
2 changed files with 15 additions and 0 deletions
|
@ -1299,6 +1299,11 @@ class When(Expression):
|
|||
template_params = extra_context
|
||||
sql_params = []
|
||||
condition_sql, condition_params = compiler.compile(self.condition)
|
||||
# Filters that match everything are handled as empty strings in the
|
||||
# WHERE clause, but in a CASE WHEN expression they must use a predicate
|
||||
# that's always True.
|
||||
if condition_sql == "":
|
||||
condition_sql, condition_params = compiler.compile(Value(True))
|
||||
template_params["condition"] = condition_sql
|
||||
sql_params.extend(condition_params)
|
||||
result_sql, result_params = compiler.compile(self.result)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue