mirror of https://github.com/django/django.git
Simplified overriding source expressions in some database functions.
This commit is contained in:
parent
b86bb47818
commit
0d7ba0ff8b
|
@ -53,14 +53,10 @@ class Coalesce(Func):
|
|||
# Oracle prohibits mixing TextField (NCLOB) and CharField (NVARCHAR2),
|
||||
# so convert all fields to NCLOB when that type is expected.
|
||||
if self.output_field.get_internal_type() == 'TextField':
|
||||
class ToNCLOB(Func):
|
||||
function = 'TO_NCLOB'
|
||||
|
||||
expressions = [
|
||||
ToNCLOB(expression) for expression in self.get_source_expressions()
|
||||
]
|
||||
clone = self.copy()
|
||||
clone.set_source_expressions(expressions)
|
||||
clone.set_source_expressions([
|
||||
Func(expression, function='TO_NCLOB') for expression in self.get_source_expressions()
|
||||
])
|
||||
return super(Coalesce, clone).as_sql(compiler, connection, **extra_context)
|
||||
return self.as_sql(compiler, connection, **extra_context)
|
||||
|
||||
|
|
|
@ -67,10 +67,9 @@ class ConcatPair(Func):
|
|||
def coalesce(self):
|
||||
# null on either side results in null for expression, wrap with coalesce
|
||||
c = self.copy()
|
||||
expressions = [
|
||||
c.set_source_expressions([
|
||||
Coalesce(expression, Value('')) for expression in c.get_source_expressions()
|
||||
]
|
||||
c.set_source_expressions(expressions)
|
||||
])
|
||||
return c
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue