diff options
Diffstat (limited to 'django')
| -rw-r--r-- | django/db/models/lookups.py | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/django/db/models/lookups.py b/django/db/models/lookups.py index 105dc93251..2683d8971a 100644 --- a/django/db/models/lookups.py +++ b/django/db/models/lookups.py @@ -262,9 +262,9 @@ class Exact(FieldGetDbPrepValueMixin, BuiltinLookup): from django.db.models.sql.query import Query if isinstance(self.rhs, Query): if self.rhs.has_limit_one(): - # The subquery must select only the pk. - self.rhs.clear_select_clause() - self.rhs.add_fields(['pk']) + if not self.rhs.has_select_fields: + self.rhs.clear_select_clause() + self.rhs.add_fields(['pk']) else: raise ValueError( 'The QuerySet value for an exact lookup must be limited to ' |
