Re: [Django] #36464: TupleIn lookup uses tuple containment even if the supports_tuple_lookups feature is disabled for right-hand-side subqueries

13 views
Skip to first unread message

Django

unread,
Jun 16, 2025, 8:10:21 AMJun 16
to django-...@googlegroups.com
#36464: TupleIn lookup uses tuple containment even if the supports_tuple_lookups
feature is disabled for right-hand-side subqueries
-------------------------------------+-------------------------------------
Reporter: Simon Charette | Owner: Simon
| Charette
Type: Bug | Status: assigned
Component: Database layer | Version: 5.2
(models, ORM) |
Severity: Release blocker | Resolution:
Keywords: composite, primary, | Triage Stage: Accepted
key |
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Jacob Walls):

* cc: composite, primary, key (removed)
* keywords: => composite, primary, key

--
Ticket URL: <https://code.djangoproject.com/ticket/36464#comment:4>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Jun 16, 2025, 9:15:31 AMJun 16
to django-...@googlegroups.com
#36464: TupleIn lookup uses tuple containment even if the supports_tuple_lookups
feature is disabled for right-hand-side subqueries
-------------------------------------+-------------------------------------
Reporter: Simon Charette | Owner: Simon
| Charette
Type: Bug | Status: assigned
Component: Database layer | Version: 5.2
(models, ORM) |
Severity: Release blocker | Resolution:
Keywords: composite, primary, | Triage Stage: Accepted
key |
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Simon Charette):

> I'm assuming we'll want some sort of low-level test against the
compiled SQL when the feature flag is false as modeled in the report.

I was thinking one thing we could do is run the `composite_pk` suite on
all backends with the feature disabled somehow. The ''fallback SQL''
should work on all backends anyway.
--
Ticket URL: <https://code.djangoproject.com/ticket/36464#comment:5>

Django

unread,
Jun 16, 2025, 10:54:51 AMJun 16
to django-...@googlegroups.com
#36464: TupleIn lookup uses tuple containment even if the supports_tuple_lookups
feature is disabled for right-hand-side subqueries
-------------------------------------+-------------------------------------
Reporter: Simon Charette | Owner: Simon
| Charette
Type: Bug | Status: assigned
Component: Database layer | Version: 5.2
(models, ORM) |
Severity: Release blocker | Resolution:
Keywords: composite primary | Triage Stage: Accepted
key |
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Jacob Walls):

* keywords: composite, primary, key => composite primary key

--
Ticket URL: <https://code.djangoproject.com/ticket/36464#comment:6>

Django

unread,
Jun 30, 2025, 10:55:35 AMJun 30
to django-...@googlegroups.com
#36464: TupleIn lookup uses tuple containment even if the supports_tuple_lookups
feature is disabled for right-hand-side subqueries
-------------------------------------+-------------------------------------
Reporter: Simon Charette | Owner: Simon
| Charette
Type: Bug | Status: assigned
Component: Database layer | Version: 5.2
(models, ORM) |
Severity: Release blocker | Resolution:
Keywords: composite primary | Triage Stage: Ready for
key | checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Natalia Bidart):

* needs_tests: 1 => 0
* stage: Accepted => Ready for checkin

--
Ticket URL: <https://code.djangoproject.com/ticket/36464#comment:7>

Django

unread,
Jun 30, 2025, 4:38:34 PMJun 30
to django-...@googlegroups.com
#36464: TupleIn lookup uses tuple containment even if the supports_tuple_lookups
feature is disabled for right-hand-side subqueries
-------------------------------------+-------------------------------------
Reporter: Simon Charette | Owner: Simon
| Charette
Type: Bug | Status: assigned
Component: Database layer | Version: 5.2
(models, ORM) |
Severity: Release blocker | Resolution:
Keywords: composite primary | Triage Stage: Accepted
key |
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Natalia Bidart):

* needs_better_patch: 0 => 1
* stage: Ready for checkin => Accepted

--
Ticket URL: <https://code.djangoproject.com/ticket/36464#comment:8>

Django

unread,
Jun 30, 2025, 4:39:11 PMJun 30
to django-...@googlegroups.com
#36464: TupleIn lookup uses tuple containment even if the supports_tuple_lookups
feature is disabled for right-hand-side subqueries
-------------------------------------+-------------------------------------
Reporter: Simon Charette | Owner: Simon
| Charette
Type: Bug | Status: assigned
Component: Database layer | Version: 5.2
(models, ORM) |
Severity: Release blocker | Resolution:
Keywords: composite primary | Triage Stage: Accepted
key |
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Natalia Bidart):

There is a consistently failing test in oracle 19, likely due a "lack of
cloning" which I can't debug right now.
--
Ticket URL: <https://code.djangoproject.com/ticket/36464#comment:9>

Django

unread,
Jun 30, 2025, 5:02:11 PMJun 30
to django-...@googlegroups.com
#36464: TupleIn lookup uses tuple containment even if the supports_tuple_lookups
feature is disabled for right-hand-side subqueries
-------------------------------------+-------------------------------------
Reporter: Simon Charette | Owner: Simon
| Charette
Type: Bug | Status: assigned
Component: Database layer | Version: 5.2
(models, ORM) |
Severity: Release blocker | Resolution:
Keywords: composite primary | Triage Stage: Accepted
key |
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Natalia Bidart):

* needs_better_patch: 1 => 0

--
Ticket URL: <https://code.djangoproject.com/ticket/36464#comment:10>

Django

unread,
Jun 30, 2025, 7:14:32 PMJun 30
to django-...@googlegroups.com
#36464: TupleIn lookup uses tuple containment even if the supports_tuple_lookups
feature is disabled for right-hand-side subqueries
-------------------------------------+-------------------------------------
Reporter: Simon Charette | Owner: Simon
| Charette
Type: Bug | Status: assigned
Component: Database layer | Version: 5.2
(models, ORM) |
Severity: Release blocker | Resolution:
Keywords: composite primary | Triage Stage: Ready for
key | checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Natalia Bidart):

* stage: Accepted => Ready for checkin

--
Ticket URL: <https://code.djangoproject.com/ticket/36464#comment:11>

Django

unread,
Jun 30, 2025, 7:15:37 PMJun 30
to django-...@googlegroups.com
#36464: TupleIn lookup uses tuple containment even if the supports_tuple_lookups
feature is disabled for right-hand-side subqueries
-------------------------------------+-------------------------------------
Reporter: Simon Charette | Owner: Simon
| Charette
Type: Bug | Status: closed
Component: Database layer | Version: 5.2
(models, ORM) |
Severity: Release blocker | Resolution: fixed
Keywords: composite primary | Triage Stage: Ready for
key | checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by nessita <124304+nessita@…>):

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

Comment:

In [changeset:"192bc7a7be92e20cc250907fb4083df689715679" 192bc7a7]:
{{{#!CommitTicketReference repository=""
revision="192bc7a7be92e20cc250907fb4083df689715679"
Fixed #36464 -- Fixed "__in" tuple lookup on backends lacking native
support.

When native support for tuple lookups is missing in a DB backend, it can
be emulated with an EXISTS clause. This is controlled by the backend
feature flag "supports_tuple_lookups".

The mishandling of subquery right-hand side in `TupleIn` (added to
support `CompositePrimaryKey` in Refs #373) was likely missed because
the only core backend we test with the feature flag disabled
(Oracle < 23.4) supports it natively.

Thanks to Nandana Raol for the report, and to Sarah Boyce, Jacob Walls,
and Natalia Bidart for reviews.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/36464#comment:12>

Django

unread,
Jun 30, 2025, 7:16:32 PMJun 30
to django-...@googlegroups.com
#36464: TupleIn lookup uses tuple containment even if the supports_tuple_lookups
feature is disabled for right-hand-side subqueries
-------------------------------------+-------------------------------------
Reporter: Simon Charette | Owner: Simon
| Charette
Type: Bug | Status: closed
Component: Database layer | Version: 5.2
(models, ORM) |
Severity: Release blocker | Resolution: fixed
Keywords: composite primary | Triage Stage: Ready for
key | checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Natalia <124304+nessita@…>):

In [changeset:"a150160c9fc6ba6220f1e63863b03e7f7978b747" a150160]:
{{{#!CommitTicketReference repository=""
revision="a150160c9fc6ba6220f1e63863b03e7f7978b747"
[5.2.x] Fixed #36464 -- Fixed "__in" tuple lookup on backends lacking
native support.

When native support for tuple lookups is missing in a DB backend, it can
be emulated with an EXISTS clause. This is controlled by the backend
feature flag "supports_tuple_lookups".

The mishandling of subquery right-hand side in `TupleIn` (added to
support `CompositePrimaryKey` in Refs #373) was likely missed because
the only core backend we test with the feature flag disabled
(Oracle < 23.4) supports it natively.

Thanks to Nandana Raol for the report, and to Sarah Boyce, Jacob Walls,
and Natalia Bidart for reviews.

Backport of 192bc7a7be92e20cc250907fb4083df689715679 from main.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/36464#comment:13>
Reply all
Reply to author
Forward
0 new messages