summaryrefslogtreecommitdiff
path: root/django/db/models/sql
diff options
context:
space:
mode:
Diffstat (limited to 'django/db/models/sql')
-rw-r--r--django/db/models/sql/query.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/django/db/models/sql/query.py b/django/db/models/sql/query.py
index 61c1e51557..432e5e6332 100644
--- a/django/db/models/sql/query.py
+++ b/django/db/models/sql/query.py
@@ -313,6 +313,18 @@ class BaseQuery(object):
params.extend(self.extra_params)
return ' '.join(result), tuple(params)
+ def as_nested_sql(self):
+ """
+ Perform the same functionality as the as_sql() method, returning an
+ SQL string and parameters. However, the alias prefixes are bumped
+ beforehand (in a copy -- the current query isn't changed).
+
+ Used when nesting this query inside another.
+ """
+ obj = self.clone()
+ obj.bump_prefix()
+ return obj.as_sql()
+
def combine(self, rhs, connector):
"""
Merge the 'rhs' query into the current one (with any 'rhs' effects