#34533: OuterRef not resolved as part oh ORDER BY clause
-------------------------------------+-------------------------------------
     Reporter:  REGNIER Guillaume    |                    Owner:  (none)
         Type:  Bug                  |                   Status:  new
    Component:  Database layer       |                  Version:  3.2
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:
     Keywords:  OuterRef, OrderBy    |             Triage Stage:  Accepted
    Has patch:  1                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  1
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Comment (by Chris M):

 I am able to reproduce this issue with a simple unit test still against
 the main branch.

 {{{#!diff
 diff --git a/tests/queries/tests.py b/tests/queries/tests.py
 index ec88fa558d..a9dd943ee8 100644
 --- a/tests/queries/tests.py
 +++ b/tests/queries/tests.py
 @@ -2377,6 +2377,13 @@ class SubqueryTests(TestCase):
          NamedCategory.objects.create(id=3, name="third")
          NamedCategory.objects.create(id=4, name="fourth")

 +    def test_outer_ref_order_by(self):
 +        values = NamedCategory.objects.annotate(
 +
 foo=NamedCategory.objects.order_by(OuterRef("pk").desc()).values("name")
 +        ).first()
 +
 +        self.assertEqual(["fourth", "third", "second", "first"],
 values.foo)
 +
      def test_ordered_subselect(self):
          "Subselects honor any manual ordering"
          query = DumbCategory.objects.filter(
 }}}
-- 
Ticket URL: <https://code.djangoproject.com/ticket/34533#comment:17>
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 django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/010701911e8df36b-4eedff1d-72b7-4aab-b73a-15fdca218c0a-000000%40eu-central-1.amazonses.com.

Reply via email to