18 lines
758 B
Diff
18 lines
758 B
Diff
# django__django-11797
|
|
# Loki Mode Multi-Agent Patch
|
|
# Attempts: 1
|
|
|
|
--- a/django/db/models/lookups.py
|
|
+++ b/django/db/models/lookups.py
|
|
@@ -262,9 +262,10 @@ class Exact(FieldGetDbPrepValueIterableMixin, BuiltinLookup):
|
|
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 getattr(self.rhs, 'has_select_fields', True):
|
|
+ self.rhs.clear_select_clause()
|
|
+ self.rhs.add_fields(['pk'])
|
|
else:
|
|
raise ValueError(
|
|
'The QuerySet value for an exact lookup must be limited to '
|