Refs #33895 -- Fixed Case() crash with filters that match everything in When() on Oracle.

Follow up to 036bb2b74a.
This commit is contained in:
Mariusz Felisiak 2022-08-10 12:28:39 +02:00 committed by GitHub
parent 9e7cb27a5b
commit 721706f4c4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 4 deletions

View File

@ -1303,14 +1303,19 @@ class When(Expression):
# 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))
if connection.features.supports_boolean_expr_in_select_clause:
condition_sql, condition_params = compiler.compile(Value(True))
else:
condition_sql, condition_params = "1=1", ()
template_params["condition"] = condition_sql
sql_params.extend(condition_params)
result_sql, result_params = compiler.compile(self.result)
template_params["result"] = result_sql
sql_params.extend(result_params)
template = template or self.template
return template % template_params, sql_params
return template % template_params, (
*sql_params,
*condition_params,
*result_params,
)
def get_group_by_cols(self, alias=None):
# This is not a complete expression and cannot be used in GROUP BY.