From 9d0c600d8d6359107cdbef5f0c30757321da09f6 Mon Sep 17 00:00:00 2001 From: Adam Chainz Date: Wed, 8 Apr 2015 22:26:09 +0100 Subject: [PATCH] Fixed #24609 -- Made ConcatPair use CONCAT_WS() on MySQL --- django/db/models/functions.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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):