diff --git a/django/db/models/functions/comparison.py b/django/db/models/functions/comparison.py index 6c0b33bdcc..24c3c4b4b8 100644 --- a/django/db/models/functions/comparison.py +++ b/django/db/models/functions/comparison.py @@ -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) diff --git a/django/db/models/functions/text.py b/django/db/models/functions/text.py index 9624f0911f..6216cbf6e6 100644 --- a/django/db/models/functions/text.py +++ b/django/db/models/functions/text.py @@ -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