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:58:17 -0400
commit42e029f6c4d9b03a238c3f8b479258ca2cb034ed (patch)
tree9debf06dbbc2298068bee20552d9bacde2f5afb0 /django
parenta8133e73a70e95fbe891ce38a7c44aefd8910c34 (diff)
[1.8.x] Fixed #25517 -- Made Concat function idempotent on SQLite.
Backport of 6c95b134e9b2d5641c123551c080305e90e6a89d from master
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 610ecb6985..531f9a882f 100644
--- a/django/db/models/functions.py
+++ b/django/db/models/functions.py
@@ -41,10 +41,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):
self.coalesce()
@@ -52,9 +52,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):