[Django] #36808: Make UniqueConstraint name required in signature

3 views
Skip to first unread message

Django

unread,
Dec 18, 2025, 8:48:13 AM12/18/25
to django-...@googlegroups.com
#36808: Make UniqueConstraint name required in signature
-------------------------------------+-------------------------------------
Reporter: Jonathan | Owner: Jonathan Biemond
Biemond |
Type: | Status: assigned
Cleanup/optimization |
Component: Database | Version: 6.0
layer (models, ORM) |
Severity: Normal | Keywords:
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 1
UI/UX: 0 |
-------------------------------------+-------------------------------------
A `UniqueConstraint` requires a `name` argument, but is declared optional
(`=None`) in its signature. If `name` is omitted a `ValueError` is raised.
This may be confusing to developers.

The `name` argument was first made optional in the signature in commit
[3aa545281], which introduced support for functional unique constraints,
addressing ticket #30016.

More discussion on the forum: https://forum.djangoproject.com/t/make-
uniqueconstraint-name-required-in-signature/43664
--
Ticket URL: <https://code.djangoproject.com/ticket/36808>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Dec 18, 2025, 8:57:47 AM12/18/25
to django-...@googlegroups.com
#36808: Make UniqueConstraint name required in signature
-------------------------------------+-------------------------------------
Reporter: Jonathan Biemond | Owner: Jonathan
Type: | Biemond
Cleanup/optimization | Status: assigned
Component: Database layer | Version: 6.0
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Jonathan Biemond):

* has_patch: 0 => 1

--
Ticket URL: <https://code.djangoproject.com/ticket/36808#comment:1>

Django

unread,
Dec 18, 2025, 10:40:40 AM12/18/25
to django-...@googlegroups.com
#36808: Make UniqueConstraint name required in signature
-------------------------------------+-------------------------------------
Reporter: Jonathan Biemond | Owner: Jonathan
Type: | Biemond
Cleanup/optimization | Status: assigned
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Jacob Walls):

* stage: Unreviewed => Accepted
* version: 6.0 => dev

Comment:

Thanks. #36262 is a related ticket as Clifford pointed out on the forum.
--
Ticket URL: <https://code.djangoproject.com/ticket/36808#comment:2>

Django

unread,
Dec 18, 2025, 1:25:50 PM12/18/25
to django-...@googlegroups.com
#36808: Make UniqueConstraint name required in signature
-------------------------------------+-------------------------------------
Reporter: Jonathan Biemond | Owner: Jonathan
Type: | Biemond
Cleanup/optimization | Status: assigned
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Jacob Walls):

* stage: Accepted => Ready for checkin

--
Ticket URL: <https://code.djangoproject.com/ticket/36808#comment:3>

Django

unread,
Dec 19, 2025, 9:48:26 AM12/19/25
to django-...@googlegroups.com
#36808: Make UniqueConstraint name required in signature
-------------------------------------+-------------------------------------
Reporter: Jonathan Biemond | Owner: Jonathan
Type: | Biemond
Cleanup/optimization | Status: closed
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Jacob Walls <jacobtylerwalls@…>):

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

Comment:

In [changeset:"b172cbdf33c3eaea6a5c4a53da2ed0e46306a625" b172cbd]:
{{{#!CommitTicketReference repository=""
revision="b172cbdf33c3eaea6a5c4a53da2ed0e46306a625"
Fixed #36808 -- Required name argument in UniqueConstraint signature.

By trading ValueError for TypeError for omitted name arguments,
we gain a little clarity.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/36808#comment:4>
Reply all
Reply to author
Forward
0 new messages