summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
authorJosh Smeaton <josh.smeaton@gmail.com>2015-10-14 10:07:42 +1100
committerTim Graham <timograham@gmail.com>2015-10-17 15:51:04 -0400
commit6c95b134e9b2d5641c123551c080305e90e6a89d (patch)
tree10846791986188d080f477fd676a6741ee5b9274 /django
parent0922bbf18d3ae8f37e1823df2dbc270d33334548 (diff)
Fixed #25517 -- Made Concat function idempotent on SQLite.
Diffstat (limited to 'django')
-rw-r--r--django/db/models/functions.py15
1 files changed, 9 insertions, 6 deletions
diff --git a/django/db/models/functions.py b/django/db/models/functions.py
index ac24aa7bdc..ffa3e36084 100644
--- a/django/db/models/functions.py
+++ b/django/db/models/functions.py
@@ -42,10 +42,10 @@ class ConcatPair(Func):
super(ConcatPair, self).__init__(left, right, **extra)
def as_sqlite(self, compiler, connection):
- self.arg_joiner = ' || '
- self.template = '%(expressions)s'
- self.coalesce()
- return super(ConcatPair, self).as_sql(compiler, connection)
+ coalesced = self.coalesce()
+ coalesced.arg_joiner = ' || '
+ coalesced.template = '%(expressions)s'
+ return super(ConcatPair, coalesced).as_sql(compiler, connection)
def as_mysql(self, compiler, connection):
# Use CONCAT_WS with an empty separator so that NULLs are ignored.
@@ -55,9 +55,12 @@ class ConcatPair(Func):
def coalesce(self):
# null on either side results in null for expression, wrap with coalesce
+ c = self.copy()
expressions = [
- Coalesce(expression, Value('')) for expression in self.get_source_expressions()]
- self.set_source_expressions(expressions)
+ Coalesce(expression, Value('')) for expression in c.get_source_expressions()
+ ]
+ c.set_source_expressions(expressions)
+ return c
class Concat(Func):