Changes between Version 1 and Version 2 of Ticket #33975, comment 8


Ignore:
Timestamp:
Sep 5, 2022, 9:08:18 PM (2 years ago)
Author:
Simon Charette

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #33975, comment 8

    v1 v2  
    22
    33This should not be necessary as it's a shallow attribute and it already gets carried over.
     4
     5The tests are failing because `RelatedIn` also needs adjustments to make sure it goes through `Query.set_values` instead of calling `clear_select_clause` and `add_fields`
     6
     7{{{#!diff
     8diff --git a/django/db/models/fields/related_lookups.py b/django/db/models/fields/related_lookups.py
     9index 1a845a1f7f..afea09b5a9 100644
     10--- a/django/db/models/fields/related_lookups.py
     11+++ b/django/db/models/fields/related_lookups.py
     12@@ -93,7 +93,6 @@ def get_prep_lookup(self):
     13             elif not getattr(self.rhs, "has_select_fields", True) and not getattr(
     14                 self.lhs.field.target_field, "primary_key", False
     15             ):
     16-                self.rhs.clear_select_clause()
     17                 if (
     18                     getattr(self.lhs.output_field, "primary_key", False)
     19                     and self.lhs.output_field.model == self.rhs.model
     20@@ -105,7 +104,7 @@ def get_prep_lookup(self):
     21                     target_field = self.lhs.field.name
     22                 else:
     23                     target_field = self.lhs.field.target_field.name
     24-                self.rhs.add_fields([target_field], True)
     25+                self.rhs.set_values([target_field])
     26         return super().get_prep_lookup()
     27
     28     def as_sql(self, compiler, connection):
     29}}}
Back to Top