mirror of
https://github.com/django/django.git
synced 2025-10-31 09:41:08 +00:00
Fixed #28175 -- Fixed __in lookups on a foreign key when using the foreign key's parent model as the lookup value.
Thanks Simon Charette for review.
This commit is contained in:
@@ -81,7 +81,8 @@ class RelatedIn(In):
|
||||
AND)
|
||||
return root_constraint.as_sql(compiler, connection)
|
||||
else:
|
||||
if not getattr(self.rhs, 'has_select_fields', True):
|
||||
if (not getattr(self.rhs, 'has_select_fields', True) and
|
||||
not getattr(self.lhs.field.target_field, 'primary_key', False)):
|
||||
self.rhs.clear_select_clause()
|
||||
if (getattr(self.lhs.output_field, 'primary_key', False) and
|
||||
self.lhs.output_field.model == self.rhs.model):
|
||||
|
||||
Reference in New Issue
Block a user