Fixed #23493 -- Added bilateral attribute to Transform

This commit is contained in:
Thomas Chaumeny 2014-09-14 12:34:41 +02:00 committed by Anssi Kääriäinen
parent 6b39401baf
commit 00aa562884
6 changed files with 268 additions and 28 deletions

View file

@ -1111,18 +1111,21 @@ class Query(object):
def build_lookup(self, lookups, lhs, rhs):
lookups = lookups[:]
bilaterals = []
while lookups:
lookup = lookups[0]
if len(lookups) == 1:
final_lookup = lhs.get_lookup(lookup)
if final_lookup:
return final_lookup(lhs, rhs)
return final_lookup(lhs, rhs, bilaterals)
# We didn't find a lookup, so we are going to try get_transform
# + get_lookup('exact').
lookups.append('exact')
next = lhs.get_transform(lookup)
if next:
lhs = next(lhs, lookups)
if getattr(next, 'bilateral', False):
bilaterals.append((next, lookups))
else:
raise FieldError(
"Unsupported lookup '%s' for %s or join on the field not "