MCPcopy
hub / github.com/django/django / demote_joins

Method demote_joins

django/db/models/sql/query.py:972–989  ·  view source on GitHub ↗

Change join type from LOUTER to INNER for all joins in aliases. Similarly to promote_joins(), this method must ensure no join chains containing first an outer, then an inner join are generated. If we are demoting b->c join in chain a LOUTER b LOUTER c then we must

(self, aliases)

Source from the content-addressed store, hash-verified

970 )
971
972 def demote_joins(self, aliases):
973 """
974 Change join type from LOUTER to INNER for all joins in aliases.
975
976 Similarly to promote_joins(), this method must ensure no join chains
977 containing first an outer, then an inner join are generated. If we
978 are demoting b->c join in chain a LOUTER b LOUTER c then we must
979 demote a->b automatically, or otherwise the demotion of b->c doesn't
980 actually change anything in the query results. .
981 """
982 aliases = list(aliases)
983 while aliases:
984 alias = aliases.pop(0)
985 if self.alias_map[alias].join_type == LOUTER:
986 self.alias_map[alias] = self.alias_map[alias].demote()
987 parent_alias = self.alias_map[alias].parent_alias
988 if self.alias_map[parent_alias].join_type == INNER:
989 aliases.append(parent_alias)
990
991 def reset_refcounts(self, to_counts):
992 """

Callers 2

add_qMethod · 0.95
update_join_typesMethod · 0.80

Calls 3

demoteMethod · 0.80
popMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected