#29142: OuterRef not being treated as an F Expression
-------------------------------------+-------------------------------------
               Reporter:             |          Owner:  nobody
  michaeljohnbarr                    |
                   Type:  Bug        |         Status:  new
              Component:  Database   |        Version:  2.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          |
-------------------------------------+-------------------------------------
 [https://docs.djangoproject.com/en/2.0/ref/models/expressions
 /#referencing-columns-from-the-outer-queryset According to the
 documentation on models.OuterRef]:

 "It acts like an F expression except that the check to see if it refers to
 a valid field isn’t made until the outer queryset is resolved."

 I am experiencing an issue with this using the following example:

 {{{
 class ExampleModel(models.Model):
     date = models.DateField()
     value = models.IntegerField()


 subquery = ExampleModel.objects.filter(
     date__gte=models.OuterRef('date') - timedelta(days=2),
     date__lte=models.OuterRef('date') + timedelta(days=2),
     value__lte=5
 )
 queryset = ExampleModel.objects.annotate(
     value_is_lte_five=models.Exists(subquery)
 )
 }}}


 The result that I am getting is:

 AttributeError: 'ResolvedOuterRef' object has no attribute
 'relabeled_clone'

 From my understanding, if this is similar to an F Expression, you should
 be able to perform the timedelta on the OuterRef.
 [https://stackoverflow.com/questions/48230771/is-it-possible-to-do-
 arithmetic-operation-on-outerref-expression I also found someone else on
 StackOverflow with the same issue].

 What I would like to know is if this is a bug (e.g. should it be
 supported), or a documentation issue.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/29142>
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 post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/058.683c291fe6ed040829a399ba4cb7381f%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to