#34533: OuterRef not resolved as part oh ORDER BY clause
-------------------------------------+-------------------------------------
Reporter: Alombaros | Owner: nobody
Type: Bug | Status: new
Component: Database | Version: 3.2
layer (models, ORM) |
Severity: Normal | Keywords: OuterRef, OrderBy
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
I feel like OuterRef are not resolved properly where used for ordering.
Here is a simple example showcasing the issue:
{{{
MyModel.objects.annotate(foo=Subquery(MyModel.objects.order_by("pk" -
OuterRef("pk")).values("pk")[:1]))
}}}
The above fails with :
{{{ ValueError: This queryset contains a reference to an outer query and
may only be used in a subquery. }}}
Because the as_sql method of ResolvedOuterRef is called.
I think this a bug because it did not raise any notice regarding OuterRef
and order_by not being compatible.
--
Ticket URL: <https://code.djangoproject.com/ticket/34533>
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/01070187e096acca-3d7fb85e-6a07-4525-a53b-3e92b31c98e0-000000%40eu-central-1.amazonses.com.