Removed field.field check in setup_joins()

This commit is contained in:
Anssi Kääriäinen 2015-02-26 15:44:41 +02:00 committed by Tim Graham
parent b68212f539
commit d43aa28f67
3 changed files with 14 additions and 12 deletions

View file

@ -1038,7 +1038,7 @@ class Query(object):
"""
Checks the type of object passed to query relations.
"""
if field.rel:
if field.is_relation:
# QuerySets implement is_compatible_query_object_type() to
# determine compatibility with the given field.
if hasattr(value, 'is_compatible_query_object_type'):
@ -1164,16 +1164,10 @@ class Query(object):
# No support for transforms for relational fields
assert len(lookups) == 1
lookup_class = field.get_lookup(lookups[0])
# Undo the changes done in setup_joins() if hasattr(final_field, 'field') branch
# This hack is needed as long as the field.rel isn't like a real field.
if field.get_path_info()[-1].target_fields != sources:
target_field = field.rel
else:
target_field = field
if len(targets) == 1:
lhs = targets[0].get_col(alias, target_field)
lhs = targets[0].get_col(alias, field)
else:
lhs = MultiColSource(alias, targets, sources, target_field)
lhs = MultiColSource(alias, targets, sources, field)
condition = lookup_class(lhs, value)
lookup_type = lookup_class.lookup_name
else:
@ -1384,8 +1378,6 @@ class Query(object):
reuse = can_reuse if join.m2m else None
alias = self.join(connection, reuse=reuse)
joins.append(alias)
if hasattr(final_field, 'field'):
final_field = final_field.field
return final_field, targets, opts, joins, path
def trim_joins(self, targets, joins, path):