Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Made Extracts aware of full lookup path

  • Loading branch information...
commit ed8fab7fe8867ff3eb801c3697a426478387bb2f 1 parent 27a57b7
@akaariai akaariai authored
Showing with 11 additions and 9 deletions.
  1. +2 −1  django/db/models/lookups.py
  2. +9 −8 django/db/models/sql/query.py
View
3  django/db/models/lookups.py
@@ -6,8 +6,9 @@
class Extract(object):
- def __init__(self, lhs):
+ def __init__(self, lhs, lookups):
self.lhs = lhs
+ self.init_lookups = lookups[:]
def get_lookup(self, lookup):
return self.output_type.get_lookup(lookup)
View
17 django/db/models/sql/query.py
@@ -1082,26 +1082,27 @@ def solve_lookup_type(self, lookup):
def build_lookup(self, lookups, lhs, rhs):
lookups = lookups[:]
- lookups.reverse()
while lookups:
- lookup = lookups.pop()
+ lookup = lookups[0]
next = lhs.get_lookup(lookup)
if next:
- if not lookups:
+ if len(lookups) == 1:
# This was the last lookup, so return value lookup.
if issubclass(next, Extract):
- lhs = next(lhs)
- next = lhs.get_lookup('exact')
- return next(lhs, rhs)
+ lookups.append('exact')
+ lhs = next(lhs, lookups)
+ else:
+ return next(lhs, rhs)
else:
- lhs = next(lhs)
+ lhs = next(lhs, lookups)
# A field's get_lookup() can return None to opt for backwards
# compatibility path.
- elif len(lookups) > 1:
+ elif len(lookups) > 2:
raise FieldError(
"Unsupported lookup for field '%s'" % lhs.output_type.name)
else:
return None
+ lookups = lookups[1:]
def build_filter(self, filter_expr, branch_negated=False, current_negated=False,
can_reuse=None, connector=AND):

0 comments on commit ed8fab7

Please sign in to comment.
Something went wrong with that request. Please try again.