Re: [Django] #373: Add support for multi-column primary keys.

32 views
Skip to first unread message

Django

unread,
Nov 27, 2024, 8:56:56 AM11/27/24
to django-...@googlegroups.com
#373: Add support for multi-column primary keys.
-------------------------------------+-------------------------------------
Reporter: Jacob | Owner: Csirmaz
| Bendegúz
Type: New feature | Status: assigned
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution:
Keywords: database | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Appuchia):

* cc: Appuchia (removed)

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

Django

unread,
Nov 29, 2024, 5:23:15 AM11/29/24
to django-...@googlegroups.com
#373: Add support for multi-column primary keys.
-------------------------------------+-------------------------------------
Reporter: Jacob | Owner: Csirmaz
| Bendegúz
Type: New feature | Status: closed
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution: fixed
Keywords: database | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Sarah Boyce <42296566+sarahboyce@…>):

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

Comment:

In [changeset:"978aae4334fa71ba78a3e94408f0f3aebde8d07c" 978aae43]:
{{{#!CommitTicketReference repository=""
revision="978aae4334fa71ba78a3e94408f0f3aebde8d07c"
Fixed #373 -- Added CompositePrimaryKey.

Thanks Lily Foote and Simon Charette for reviews and mentoring
this Google Summer of Code 2024 project.

Co-authored-by: Simon Charette <chare...@gmail.com>
Co-authored-by: Lily Foote <co...@lilyf.org>
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/373#comment:211>
Django <https://code.djangoproject.com/>
The web framework for perfectionists with deadlines.

Django

unread,
Nov 29, 2024, 6:06:35 AM11/29/24
to django-...@googlegroups.com
#373: Add support for multi-column primary keys.
-------------------------------------+-------------------------------------
Reporter: Jacob | Owner: Csirmaz
| Bendegúz
Type: New feature | Status: closed
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution: fixed
Keywords: database | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Claude Paroz):

Thanks a lot to all people involved in fixing this!! I think a special
price could be granted to those contributing to closing the oldest Django
ticket :-)

Csirmaz, you are our hero of the day (and even more)!
--
Ticket URL: <https://code.djangoproject.com/ticket/373#comment:212>

Django

unread,
Nov 29, 2024, 6:16:21 AM11/29/24
to django-...@googlegroups.com
#373: Add support for multi-column primary keys.
-------------------------------------+-------------------------------------
Reporter: Jacob | Owner: Csirmaz
| Bendegúz
Type: New feature | Status: closed
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution: fixed
Keywords: database | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Peter Thomassen):

Great achievement indeed!

https://github.com/django/django/blob/978aae4334fa71ba78a3e94408f0f3aebde8d07c/docs/topics
/composite-primary-key.txt#L129-L132 says:
``ForeignObject`` is an internal API. This means it is not covered by
our
:ref:`deprecation policy <internal-release-deprecation-policy>`.

However, release notes mention various deprecation stuff around
ForeignObject, such as ForeignObject.get_reverse_joining_columns() in
release 5.0.

So, it seems like this note in the docs is in contradiction to what's
practiced. Is this a docs bug? (Then, perhaps it should be fixed before
shipping it.)

(My preference would be for ForeignObject to be public API, as it's
becoming more and more important -- e.g., when using a GeneratedField with
a related manager, and now with composite PK.)
--
Ticket URL: <https://code.djangoproject.com/ticket/373#comment:213>

Django

unread,
Nov 29, 2024, 6:21:47 AM11/29/24
to django-...@googlegroups.com
#373: Add support for multi-column primary keys.
-------------------------------------+-------------------------------------
Reporter: Jacob | Owner: Csirmaz
| Bendegúz
Type: New feature | Status: closed
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution: fixed
Keywords: database | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Sarah Boyce):

> However, release notes mention various deprecation stuff around
ForeignObject, such as ForeignObject.get_reverse_joining_columns() in
release 5.0.

Sometimes we decide to follow a deprecation process for things that are
not documented. It's decided case by case. However, when it is part of the
public api and we have to follow the deprecation policy - I think the
statement is still correct
--
Ticket URL: <https://code.djangoproject.com/ticket/373#comment:214>

Django

unread,
Nov 29, 2024, 10:59:25 AM11/29/24
to django-...@googlegroups.com
#373: Add support for multi-column primary keys.
-------------------------------------+-------------------------------------
Reporter: Jacob | Owner: Csirmaz
| Bendegúz
Type: New feature | Status: closed
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution: fixed
Keywords: database | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Csirmaz Bendegúz):

Thanks! :)
I opened 2 follow-ups:
1. #35941
2. #35953
I'm planning to work these in the coming weeks.
--
Ticket URL: <https://code.djangoproject.com/ticket/373#comment:215>

Django

unread,
Dec 2, 2024, 2:38:03 AM12/2/24
to django-...@googlegroups.com
#373: Add support for multi-column primary keys.
-------------------------------------+-------------------------------------
Reporter: Jacob | Owner: Csirmaz
| Bendegúz
Type: New feature | Status: closed
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution: fixed
Keywords: database | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Sarah Boyce <42296566+sarahboyce@…>):

In [changeset:"81cf690111e49b9cf9d8a3b8a71767f3c8685d5b" 81cf690]:
{{{#!CommitTicketReference repository=""
revision="81cf690111e49b9cf9d8a3b8a71767f3c8685d5b"
Refs #373 -- Fixed
CompositePKChecksTests.test_composite_pk_cannot_include_generated_field()
test crash on databases with no GeneratedField support.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/373#comment:216>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Dec 2, 2024, 5:03:52 AM12/2/24
to django-...@googlegroups.com
#373: Add support for multi-column primary keys.
-------------------------------------+-------------------------------------
Reporter: Jacob | Owner: Csirmaz
| Bendegúz
Type: New feature | Status: closed
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution: fixed
Keywords: database | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Sarah Boyce <42296566+sarahboyce@…>):

In [changeset:"49761ac99a064236b4280ca55f97a896913109cd" 49761ac9]:
{{{#!CommitTicketReference repository=""
revision="49761ac99a064236b4280ca55f97a896913109cd"
Refs #373 -- Simplified DatabaseIntrospection.get_constraints() tests for
composite primary keys.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/373#comment:217>

Django

unread,
Dec 5, 2024, 4:23:45 AM12/5/24
to django-...@googlegroups.com
#373: Add support for multi-column primary keys.
-------------------------------------+-------------------------------------
Reporter: Jacob | Owner: Csirmaz
| Bendegúz
Type: New feature | Status: closed
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution: fixed
Keywords: database | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Sarah Boyce <42296566+sarahboyce@…>):

In [changeset:"28f81a10190de9aa00925156c0005f6c787afeb3" 28f81a1]:
{{{#!CommitTicketReference repository=""
revision="28f81a10190de9aa00925156c0005f6c787afeb3"
Refs #373 -- Fixed CompositePrimaryKey tests if yaml isn't installed.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/373#comment:218>

Django

unread,
Dec 8, 2024, 10:49:11 PM12/8/24
to django-...@googlegroups.com
#373: Add support for multi-column primary keys.
-------------------------------------+-------------------------------------
Reporter: Jacob | Owner: Csirmaz
| Bendegúz
Type: New feature | Status: closed
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution: fixed
Keywords: database | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Csirmaz Bendegúz):

#5929 was marked as a duplicate of this ticket.
I think we should re-open it and treat it as a follow-up (#5929 - ''Add
generic `CompositeField`s'').
I'm not planning to work on this, but maybe someone else can pick it up.
--
Ticket URL: <https://code.djangoproject.com/ticket/373#comment:219>

Django

unread,
Dec 9, 2024, 1:01:41 PM12/9/24
to django-...@googlegroups.com
#373: Add support for multi-column primary keys.
-------------------------------------+-------------------------------------
Reporter: Jacob | Owner: Csirmaz
| Bendegúz
Type: New feature | Status: closed
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution: fixed
Keywords: database | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Ülgen Sarıkavak):

* cc: Ülgen Sarıkavak (removed)

--
Ticket URL: <https://code.djangoproject.com/ticket/373#comment:220>

Django

unread,
Dec 26, 2024, 9:29:16 PM12/26/24
to django-...@googlegroups.com
#373: Add support for multi-column primary keys.
-------------------------------------+-------------------------------------
Reporter: Jacob | Owner: Csirmaz
| Bendegúz
Type: New feature | Status: closed
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution: fixed
Keywords: database | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by GitHub <noreply@…>):

In [changeset:"733d3998e2b452ace5c4382a9f6efa698b576383" 733d3998]:
{{{#!CommitTicketReference repository=""
revision="733d3998e2b452ace5c4382a9f6efa698b576383"
Refs #373 -- Fixed false failure of test_error_on_comment_pk_conflict.

The test failed with "NOT NULL constraint failed" rather than
"UNIQUE constraint failed: tenant_id, comment_id".
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/373#comment:221>

Django

unread,
Jan 2, 2025, 7:04:00 AMJan 2
to django-...@googlegroups.com
#373: Add support for multi-column primary keys.
-------------------------------------+-------------------------------------
Reporter: Jacob | Owner: Csirmaz
| Bendegúz
Type: New feature | Status: closed
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution: fixed
Keywords: database | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Sarah Boyce <42296566+sarahboyce@…>):

In [changeset:"2a61b5f97c0f9ec9ff3f321090bd8e6ed609793c" 2a61b5f]:
{{{#!CommitTicketReference repository=""
revision="2a61b5f97c0f9ec9ff3f321090bd8e6ed609793c"
Refs #373 -- Errored when providing db_column to CompositePrimaryKey.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/373#comment:222>

Django

unread,
Jan 13, 2025, 5:13:40 AMJan 13
to django-...@googlegroups.com
#373: Add support for multi-column primary keys.
-------------------------------------+-------------------------------------
Reporter: Jacob | Owner: Csirmaz
| Bendegúz
Type: New feature | Status: closed
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution: fixed
Keywords: database | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Sarah Boyce <42296566+sarahboyce@…>):

In [changeset:"bfcb34076e3c0c04cb5080a37d93225444ac1b82" bfcb340]:
{{{#!CommitTicketReference repository=""
revision="bfcb34076e3c0c04cb5080a37d93225444ac1b82"
Refs #373 -- Removed unused composite pk code in SQLInsertCompiler.

This logic could only be exercised if the composite primary key included
an
AutoField but it's not allowed yet (refs #35957).

It was also slightly broken as it expected the AutoField to always be the
first
member of returning_fields.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/373#comment:223>

Django

unread,
Jan 13, 2025, 5:13:41 AMJan 13
to django-...@googlegroups.com
#373: Add support for multi-column primary keys.
-------------------------------------+-------------------------------------
Reporter: Jacob | Owner: Csirmaz
| Bendegúz
Type: New feature | Status: closed
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution: fixed
Keywords: database | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Sarah Boyce <42296566+sarahboyce@…>):

In [changeset:"20eb4bca7de945d8858d1354a8c624406c0b90bd" 20eb4bca]:
{{{#!CommitTicketReference repository=""
revision="20eb4bca7de945d8858d1354a8c624406c0b90bd"
Refs #373 -- Adjusted test allowing AutoField in composite primary keys.

This is not a properly supported feature yet and should be revisited by
refs #35957.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/373#comment:224>

Django

unread,
Feb 9, 2025, 11:45:48 AMFeb 9
to django-...@googlegroups.com
#373: Add support for multi-column primary keys.
-------------------------------------+-------------------------------------
Reporter: Jacob | Owner: Csirmaz
| Bendegúz
Type: New feature | Status: closed
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution: fixed
Keywords: database | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Mariusz Felisiak <felisiak.mariusz@…>):

In [changeset:"c326cfe3b1683e6c205f53a4ad11feba6623a399" c326cfe3]:
{{{#!CommitTicketReference repository=""
revision="c326cfe3b1683e6c205f53a4ad11feba6623a399"
Refs #373 -- Delegated Tuple compilation to compiler.

This should allow third-party backends to define Tuple.as_vendor()
overrides that are taken into consideration which calling as_sql()
directly prevents.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/373#comment:225>

Django

unread,
Feb 9, 2025, 11:46:28 AMFeb 9
to django-...@googlegroups.com
#373: Add support for multi-column primary keys.
-------------------------------------+-------------------------------------
Reporter: Jacob | Owner: Csirmaz
| Bendegúz
Type: New feature | Status: closed
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution: fixed
Keywords: database | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Mariusz Felisiak <felisiak.mariusz@…>):

In [changeset:"1ec20a8e843981eee8f1ef2760f745c655f248f1" 1ec20a8e]:
{{{#!CommitTicketReference repository=""
revision="1ec20a8e843981eee8f1ef2760f745c655f248f1"
[5.2.x] Refs #373 -- Delegated Tuple compilation to compiler.

This should allow third-party backends to define Tuple.as_vendor()
overrides that are taken into consideration which calling as_sql()
directly prevents.

Backport of c326cfe3b1683e6c205f53a4ad11feba6623a399 from main
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/373#comment:226>

Django

unread,
Jun 10, 2025, 3:44:51 AMJun 10
to django-...@googlegroups.com
#373: Add support for multi-column primary keys.
-------------------------------------+-------------------------------------
Reporter: Jacob | Owner: Csirmaz
| Bendegúz
Type: New feature | Status: closed
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution: fixed
Keywords: database | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Sarah Boyce <42296566+sarahboyce@…>):

In [changeset:"76e1ca77bc9cdfa12df9541c32b75af926dbdfea" 76e1ca77]:
{{{#!CommitTicketReference repository=""
revision="76e1ca77bc9cdfa12df9541c32b75af926dbdfea"
Refs #373 -- Doc'd that on_delete is ignored for ForeignObject.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/373#comment:227>

Django

unread,
Jun 10, 2025, 3:49:06 AMJun 10
to django-...@googlegroups.com
#373: Add support for multi-column primary keys.
-------------------------------------+-------------------------------------
Reporter: Jacob | Owner: Csirmaz
| Bendegúz
Type: New feature | Status: closed
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution: fixed
Keywords: database | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Sarah Boyce <42296566+sarahboyce@…>):

In [changeset:"264003146f951a798e573ca563d0bf817fb91ad3" 2640031]:
{{{#!CommitTicketReference repository=""
revision="264003146f951a798e573ca563d0bf817fb91ad3"
[5.2.x] Refs #373 -- Doc'd that on_delete is ignored for ForeignObject.

Backport of 76e1ca77bc9cdfa12df9541c32b75af926dbdfea from main.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/373#comment:228>

Django

unread,
Jun 30, 2025, 7:15:38 PMJun 30
to django-...@googlegroups.com
#373: Add support for multi-column primary keys.
-------------------------------------+-------------------------------------
Reporter: Jacob | Owner: Csirmaz
| Bendegúz
Type: New feature | Status: closed
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution: fixed
Keywords: database | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by nessita <124304+nessita@…>):

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/373#comment:229>

Django

unread,
Jun 30, 2025, 7:16:32 PMJun 30
to django-...@googlegroups.com
#373: Add support for multi-column primary keys.
-------------------------------------+-------------------------------------
Reporter: Jacob | Owner: Csirmaz
| Bendegúz
Type: New feature | Status: closed
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution: fixed
Keywords: database | Triage Stage: Ready for
| 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/373#comment:230>
Reply all
Reply to author
Forward
0 new messages