mirror of
https://github.com/django/django.git
synced 2025-09-23 02:33:31 +00:00
Fixed #12717 -- Corrected a problem with subqueries when using multidb routing. Thanks to Jeff Balogh for the report.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@12755 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
2287426ba6
commit
d312fa2a61
2 changed files with 35 additions and 2 deletions
|
@ -796,7 +796,7 @@ class QuerySet(object):
|
|||
Returns the internal query's SQL and parameters (as a tuple).
|
||||
"""
|
||||
obj = self.values("pk")
|
||||
if connection == connections[obj.db]:
|
||||
if obj._db is None or connection == connections[obj._db]:
|
||||
return obj.query.get_compiler(connection=connection).as_nested_sql()
|
||||
raise ValueError("Can't do subqueries with queries on different DBs.")
|
||||
|
||||
|
@ -918,7 +918,7 @@ class ValuesQuerySet(QuerySet):
|
|||
% self.__class__.__name__)
|
||||
|
||||
obj = self._clone()
|
||||
if connection == connections[obj.db]:
|
||||
if obj._db is None or connection == connections[obj._db]:
|
||||
return obj.query.get_compiler(connection=connection).as_nested_sql()
|
||||
raise ValueError("Can't do subqueries with queries on different DBs.")
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue