mirror of https://github.com/django/django.git
Fixed #22826 -- Improved internal usage of Query.setup_joins.
This commit is contained in:
parent
bf743a4d57
commit
e66896226a
|
@ -57,9 +57,9 @@ class SQLEvaluator(object):
|
||||||
self.cols.append((node, query.aggregate_select[node.name]))
|
self.cols.append((node, query.aggregate_select[node.name]))
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
field, sources, opts, join_list, path = query.setup_joins(
|
_, sources, _, join_list, path = query.setup_joins(
|
||||||
field_list, query.get_meta(),
|
field_list, query.get_meta(), query.get_initial_alias(),
|
||||||
query.get_initial_alias(), self.reuse)
|
can_reuse=self.reuse)
|
||||||
self._used_joins = join_list
|
self._used_joins = join_list
|
||||||
targets, _, join_list = query.trim_joins(sources, join_list, path)
|
targets, _, join_list = query.trim_joins(sources, join_list, path)
|
||||||
if self.reuse is not None:
|
if self.reuse is not None:
|
||||||
|
|
|
@ -1008,7 +1008,7 @@ class Query(object):
|
||||||
|
|
||||||
# Join promotion note - we must not remove any rows here, so use
|
# Join promotion note - we must not remove any rows here, so use
|
||||||
# outer join if there isn't any existing join.
|
# outer join if there isn't any existing join.
|
||||||
field, sources, opts, join_list, path = self.setup_joins(
|
_, sources, opts, join_list, path = self.setup_joins(
|
||||||
field_list, opts, self.get_initial_alias())
|
field_list, opts, self.get_initial_alias())
|
||||||
|
|
||||||
# Process the join chain to see if it can be trimmed
|
# Process the join chain to see if it can be trimmed
|
||||||
|
@ -1158,7 +1158,7 @@ class Query(object):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
field, sources, opts, join_list, path = self.setup_joins(
|
field, sources, opts, join_list, path = self.setup_joins(
|
||||||
parts, opts, alias, can_reuse, allow_many)
|
parts, opts, alias, can_reuse=can_reuse, allow_many=allow_many)
|
||||||
# split_exclude() needs to know which joins were generated for the
|
# split_exclude() needs to know which joins were generated for the
|
||||||
# lookup parts
|
# lookup parts
|
||||||
self._lookup_joins = join_list
|
self._lookup_joins = join_list
|
||||||
|
@ -1605,9 +1605,8 @@ class Query(object):
|
||||||
for name in field_names:
|
for name in field_names:
|
||||||
# Join promotion note - we must not remove any rows here, so
|
# Join promotion note - we must not remove any rows here, so
|
||||||
# if there is no existing joins, use outer join.
|
# if there is no existing joins, use outer join.
|
||||||
field, targets, u2, joins, path = self.setup_joins(
|
_, targets, _, joins, path = self.setup_joins(
|
||||||
name.split(LOOKUP_SEP), opts, alias, can_reuse=None,
|
name.split(LOOKUP_SEP), opts, alias, allow_many=allow_m2m)
|
||||||
allow_many=allow_m2m)
|
|
||||||
targets, final_alias, joins = self.trim_joins(targets, joins, path)
|
targets, final_alias, joins = self.trim_joins(targets, joins, path)
|
||||||
for target in targets:
|
for target in targets:
|
||||||
self.select.append(SelectInfo((final_alias, target.column), target))
|
self.select.append(SelectInfo((final_alias, target.column), target))
|
||||||
|
|
|
@ -215,7 +215,7 @@ class DateQuery(Query):
|
||||||
Converts the query into an extraction query.
|
Converts the query into an extraction query.
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
result = self.setup_joins(
|
field, _, _, joins, _ = self.setup_joins(
|
||||||
field_name.split(LOOKUP_SEP),
|
field_name.split(LOOKUP_SEP),
|
||||||
self.get_meta(),
|
self.get_meta(),
|
||||||
self.get_initial_alias(),
|
self.get_initial_alias(),
|
||||||
|
@ -224,9 +224,8 @@ class DateQuery(Query):
|
||||||
raise FieldDoesNotExist("%s has no field named '%s'" % (
|
raise FieldDoesNotExist("%s has no field named '%s'" % (
|
||||||
self.get_meta().object_name, field_name
|
self.get_meta().object_name, field_name
|
||||||
))
|
))
|
||||||
field = result[0]
|
|
||||||
self._check_field(field) # overridden in DateTimeQuery
|
self._check_field(field) # overridden in DateTimeQuery
|
||||||
alias = result[3][-1]
|
alias = joins[-1]
|
||||||
select = self._get_select((alias, field.column), lookup_type)
|
select = self._get_select((alias, field.column), lookup_type)
|
||||||
self.clear_select_clause()
|
self.clear_select_clause()
|
||||||
self.select = [SelectInfo(select, None)]
|
self.select = [SelectInfo(select, None)]
|
||||||
|
|
Loading…
Reference in New Issue