[Django] #37090: Combined query targeted by In fails on Oracle if deeper combined queries are ordered

2 views
Skip to first unread message

Django

unread,
May 8, 2026, 11:03:50 AM (yesterday) May 8
to django-...@googlegroups.com
#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.

Django

unread,
May 8, 2026, 11:12:06 AM (yesterday) May 8
to django-...@googlegroups.com
#37090: Combined query targeted by In fails on Oracle if deeper combined queries
are ordered
-------------------------------------+-------------------------------------
Reporter: Jacob Walls | Owner: Sidharth
| Dusanapudi
Type: Bug | Status: assigned
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Jacob Walls):

[https://github.com/django/django/pull/21247 PR]
--
Ticket URL: <https://code.djangoproject.com/ticket/37090#comment:1>

Django

unread,
May 8, 2026, 11:32:15 AM (yesterday) May 8
to django-...@googlegroups.com
#37090: Combined query targeted by In fails on Oracle if deeper combined queries
are ordered
-------------------------------------+-------------------------------------
Reporter: Jacob Walls | Owner: Sidharth
| Dusanapudi
Type: Bug | Status: closed
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution: duplicate
Keywords: | Triage Stage:
| Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Jacob Walls):

* resolution: => duplicate
* status: assigned => closed

Comment:

Sorry, this is a duplicate of #36938, the same change covers both.
--
Ticket URL: <https://code.djangoproject.com/ticket/37090#comment:2>
Reply all
Reply to author
Forward
0 new messages