From 1cdfbde4db1ac6bbddb2cf8dd5192831bc0f9ce3 Mon Sep 17 00:00:00 2001 From: Josh Smeaton Date: Mon, 29 Dec 2014 09:15:00 +1100 Subject: Fixed #23753 -- Oracle failure with Coalesce --- django/db/models/functions.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'django') diff --git a/django/db/models/functions.py b/django/db/models/functions.py index f2252000cd..f16cf10b15 100644 --- a/django/db/models/functions.py +++ b/django/db/models/functions.py @@ -16,6 +16,18 @@ class Coalesce(Func): raise ValueError('Coalesce must take at least two expressions') super(Coalesce, self).__init__(*expressions, **extra) + def as_oracle(self, compiler, connection): + # we can't mix TextField (NCLOB) and CharField (NVARCHAR), so convert + # all fields to NCLOB when we expect NCLOB + if self.output_field.get_internal_type() == 'TextField': + class ToNCLOB(Func): + function = 'TO_NCLOB' + + expressions = [ + ToNCLOB(expression) for expression in self.get_source_expressions()] + self.set_source_expressions(expressions) + return super(Coalesce, self).as_sql(compiler, connection) + class ConcatPair(Func): """ -- cgit v1.3