From f747b61c20cb2ab9bcbca2b272f3fba80cf39ac6 Mon Sep 17 00:00:00 2001 From: Malcolm Tredinnick Date: Mon, 5 Jan 2009 11:47:48 +0000 Subject: Nested query support. This extends previous functionality that allowed passing Query objects as the rvals to filters. You can now pass QuerySets, which requires less poking at opaque attributes. See the documentation of the "__in" lookup type for the details. git-svn-id: http://code.djangoproject.com/svn/django/trunk@9701 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/db/models/sql/query.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'django/db/models/sql/query.py') 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 -- cgit v1.3