diff options
| author | Tim Graham <timograham@gmail.com> | 2016-10-28 11:20:23 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2016-10-28 11:20:23 -0400 |
| commit | 1bc249c2a67c24fcd28436c85388eff1d826e305 (patch) | |
| tree | 429351ccffaed9711a00b8c4d6eae760c72ac453 /django/db/models/sql/where.py | |
| parent | 80e742d991b276023a3aa51a29ed757879051282 (diff) | |
Fixed #20939 -- Simplified query generation by converting QuerySet to Query.
Thanks Anssi Kääriäinen for the initial patch and Anssi, Simon Charette,
and Josh Smeaton for review.
Diffstat (limited to 'django/db/models/sql/where.py')
| -rw-r--r-- | django/db/models/sql/where.py | 16 |
1 files changed, 1 insertions, 15 deletions
diff --git a/django/db/models/sql/where.py b/django/db/models/sql/where.py index 04e9a7c1bd..df44803b8a 100644 --- a/django/db/models/sql/where.py +++ b/django/db/models/sql/where.py @@ -197,20 +197,6 @@ class SubqueryConstraint(object): def as_sql(self, compiler, connection): query = self.query_object - - # QuerySet was sent - if hasattr(query, 'values'): - if query._db and connection.alias != query._db: - raise ValueError("Can't do subqueries with queries on different DBs.") - # Do not override already existing values. - if query._fields is None: - query = query.values(*self.targets) - else: - query = query._clone() - query = query.query - if query.can_filter(): - # If there is no slicing in use, then we can safely drop all ordering - query.clear_ordering(True) - + query.set_values(self.targets) query_compiler = query.get_compiler(connection=connection) return query_compiler.as_subquery_condition(self.alias, self.columns, compiler) |
