mirror of
https://github.com/django/django.git
synced 2025-08-24 12:34:09 +00:00
Refs #25367 -- Simplified OrderBy and Lookup by using Case() instead of RawSQL() on Oracle.
Follow up to efa1908f66
.
This commit is contained in:
parent
4137fc2efc
commit
d275fd04f3
2 changed files with 10 additions and 12 deletions
|
@ -1163,11 +1163,11 @@ class OrderBy(BaseExpression):
|
|||
# a CASE WHEN.
|
||||
if isinstance(self.expression, Exists):
|
||||
copy = self.copy()
|
||||
# XXX: Use Case(When(self.lhs)) once support for boolean
|
||||
# expressions is added to When.
|
||||
exists_sql, params = compiler.compile(self.expression)
|
||||
case_sql = 'CASE WHEN %s THEN 1 ELSE 0 END' % exists_sql
|
||||
copy.expression = RawSQL(case_sql, params)
|
||||
copy.expression = Case(
|
||||
When(self.expression, then=True),
|
||||
default=False,
|
||||
output_field=fields.BooleanField(),
|
||||
)
|
||||
return copy.as_sql(compiler, connection)
|
||||
return self.as_sql(compiler, connection)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue