#37090: Combined query targeted by In fails on Oracle if deeper combined queries
are ordered
-------------------------------------+-------------------------------------
Reporter: Jacob | Owner: Sidharth Dusanapudi
Walls |
Type: Bug | Status: assigned
Component: Database | Version: dev
layer (models, ORM) |
Severity: Normal | Keywords:
Triage Stage: | Has patch: 1
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
During [
https://github.com/django/django/pull/21102/changes#r3204761827
review] of a related PR for #36938, we discovered another Oracle-only
failure relating to clearing of unnecessary order_by inside unions.
We noticed `test_union_in_with_ordering` added in #33796 only accounts for
one depth.
Failing test:
{{{#!py
@skipUnlessDBFeature("supports_slicing_ordering_in_compound")
def test_union_in_with_ordering_union(self):
qs1 = Number.objects.filter(num__gt=7).order_by("id")
qs2 = Number.objects.filter(num__lt=2).order_by("-id")
qs3 = Number.objects.filter(num=5).order_by("id")
union = qs1.union(qs2).order_by("id")
self.assertNumbersEqual(
Number.objects.exclude(
id__in=union.union(qs3).order_by("-id").values("id")
),
[2, 3, 4, 6, 7],
ordered=False,
)
}}}
{{{
django.db.utils.DatabaseError: ORA-00907: missing right parenthesis
Help:
https://docs.oracle.com/error-help/db/ora-00907/
}}}
I'll extract the changes into a separate PR.
--
Ticket URL: <
https://code.djangoproject.com/ticket/37090>
Django <
https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.