1
0
mirror of https://github.com/django/django.git synced 2025-10-25 22:56:12 +00:00

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
This commit is contained in:
Malcolm Tredinnick
2009-01-05 11:47:48 +00:00
parent 062a94ef45
commit f747b61c20
4 changed files with 59 additions and 7 deletions

View File

@@ -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