summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJosh Smeaton <josh.smeaton@gmail.com>2015-10-19 12:06:11 +1100
committerJosh Smeaton <josh.smeaton@gmail.com>2015-10-19 12:06:11 +1100
commit61ea3718224e6264f2d21858da70e3cbff3bd72e (patch)
tree5379e6348ac9ba9cef72c6278ac243effe8b9f60
parent42e029f6c4d9b03a238c3f8b479258ca2cb034ed (diff)
downloaddjango-61ea3718224e6264f2d21858da70e3cbff3bd72e.tar.gz
Refs #25517 -- Fixed backport inconsistencies.
-rw-r--r--django/db/models/expressions.py11
-rw-r--r--django/db/models/functions.py4
2 files changed, 13 insertions, 2 deletions
diff --git a/django/db/models/expressions.py b/django/db/models/expressions.py
index d3769b49a9..5d6fab6595 100644
--- a/django/db/models/expressions.py
+++ b/django/db/models/expressions.py
@@ -339,6 +339,17 @@ class BaseExpression(object):
def reverse_ordering(self):
return self
+ def flatten(self):
+ """
+ Recursively yield this expression and all subexpressions, in
+ depth-first order.
+ """
+ yield self
+ for expr in self.get_source_expressions():
+ if expr:
+ for inner_expr in expr.flatten():
+ yield inner_expr
+
class Expression(BaseExpression, Combinable):
"""
diff --git a/django/db/models/functions.py b/django/db/models/functions.py
index 531f9a882f..92665a658a 100644
--- a/django/db/models/functions.py
+++ b/django/db/models/functions.py
@@ -47,8 +47,8 @@ class ConcatPair(Func):
return super(ConcatPair, coalesced).as_sql(compiler, connection)
def as_mysql(self, compiler, connection):
- self.coalesce()
- return super(ConcatPair, self).as_sql(compiler, connection)
+ coalesced = self.coalesce()
+ return super(ConcatPair, coalesced).as_sql(compiler, connection)
def coalesce(self):
# null on either side results in null for expression, wrap with coalesce