summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Chainz <adam@adamj.eu>2015-04-08 22:26:09 +0100
committerTim Graham <timograham@gmail.com>2015-04-09 10:17:27 -0400
commit9d0c600d8d6359107cdbef5f0c30757321da09f6 (patch)
tree7b2ff2597c4798069f838645c9dcc43d0e0be0d4
parent418f75d55f2612066b5bd27171026c20af317716 (diff)
downloaddjango-9d0c600d8d6359107cdbef5f0c30757321da09f6.tar.gz
Fixed #24609 -- Made ConcatPair use CONCAT_WS() on MySQL
-rw-r--r--django/db/models/functions.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/django/db/models/functions.py b/django/db/models/functions.py
index 610ecb6985..613d396093 100644
--- a/django/db/models/functions.py
+++ b/django/db/models/functions.py
@@ -47,7 +47,9 @@ class ConcatPair(Func):
return super(ConcatPair, self).as_sql(compiler, connection)
def as_mysql(self, compiler, connection):
- self.coalesce()
+ # Use CONCAT_WS with an empty separator so that NULLs are ignored.
+ self.function = 'CONCAT_WS'
+ self.template = "%(function)s('', %(expressions)s)"
return super(ConcatPair, self).as_sql(compiler, connection)
def coalesce(self):