#31714: ResolvedOuterRef object has no get_lookup
-------------------------------------+-------------------------------------
               Reporter:  BorisZZZ   |          Owner:  nobody
                   Type:  Bug        |         Status:  new
              Component:  Database   |        Version:  3.0
  layer (models, ORM)                |
               Severity:  Normal     |       Keywords:
           Triage Stage:             |      Has patch:  0
  Unreviewed                         |
    Needs documentation:  0          |    Needs tests:  0
Patch needs improvement:  0          |  Easy pickings:  0
                  UI/UX:  0          |
-------------------------------------+-------------------------------------
 This looks like an issue very similar to #28621, only in this case the
 issue is cause by using the annotation on the LHS of a filter.
 For example,
 {{{
 class A(models.Model):
     r = IntegerRangeField()

 A.objects.annotate(x=OuterRef("x")).filter(x__contained_in=F("r"))
 }}}
 will result in the following stack trace:
 {{{
 Traceback (most recent call last):
   ...
   File "/usr/local/lib/python3.8/site-packages/django/db/models/query.py",
 line 904, in filter
     return self._filter_or_exclude(False, *args, **kwargs)
   File "/usr/local/lib/python3.8/site-packages/django/db/models/query.py",
 line 923, in _filter_or_exclude
     clone.query.add_q(Q(*args, **kwargs))
   File "/usr/local/lib/python3.8/site-
 packages/django/db/models/sql/query.py", line 1350, in add_q
     clause, _ = self._add_q(q_object, self.used_aliases)
   File "/usr/local/lib/python3.8/site-
 packages/django/db/models/sql/query.py", line 1377, in _add_q
     child_clause, needed_inner = self.build_filter(
   File "/usr/local/lib/python3.8/site-
 packages/django/db/models/sql/query.py", line 1267, in build_filter
     condition = self.build_lookup(lookups, reffed_expression, value)
   File "/usr/local/lib/python3.8/site-
 packages/django/db/models/sql/query.py", line 1153, in build_lookup
     lookup_class = lhs.get_lookup(lookup_name)
 AttributeError: 'ResolvedOuterRef' object has no attribute 'get_lookup'
 }}}

-- 
Ticket URL: <https://code.djangoproject.com/ticket/31714>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/051.32f6e6d0f1a8e3b735ffd34ff1a501a9%40djangoproject.com.

Reply via email to