diff options
| author | Nick Pope <nick.pope@flightdataservices.com> | 2019-01-13 21:58:09 +0000 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2019-01-14 13:02:58 -0500 |
| commit | 0d7ba0ff8bb157f6646c1836cc1c658171e7674c (patch) | |
| tree | 946b526b7c9db2fef4b0aabbbaee9b7192a41fe4 | |
| parent | b86bb47818e159e8db7e524ed8ef055b569ea111 (diff) | |
Simplified overriding source expressions in some database functions.
| -rw-r--r-- | django/db/models/functions/comparison.py | 10 | ||||
| -rw-r--r-- | django/db/models/functions/text.py | 5 |
2 files changed, 5 insertions, 10 deletions
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 |
