[Django] #32780: Make covering UniqueConstraint on SQLite a no-op

16 views
Skip to first unread message

Django

unread,
May 24, 2021, 4:05:28 PM5/24/21
to django-...@googlegroups.com
#32780: Make covering UniqueConstraint on SQLite a no-op
-------------------------------------+-------------------------------------
Reporter: Hannes | Owner: Hannes Ljungberg
Ljungberg |
Type: Bug | Status: assigned
Component: | Version: dev
Migrations |
Severity: Normal | Keywords:
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
Creating a constraint like `UniqueConstraint(fields=['name'],
name='name_unq_covering', include=['weight'])` on SQLite will issue the
warning `models.W039` stating that a constraint won't be created even
though it is.

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

Django

unread,
May 24, 2021, 4:09:05 PM5/24/21
to django-...@googlegroups.com
#32780: Make covering UniqueConstraint on SQLite a no-op
-------------------------------------+-------------------------------------
Reporter: Hannes Ljungberg | Owner: Hannes

| Ljungberg
Type: Bug | Status: assigned
Component: Migrations | Version: dev
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
-------------------------------------+-------------------------------------
Changes (by Hannes Ljungberg):

* has_patch: 0 => 1


Comment:

PR: https://github.com/django/django/pull/14444

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

Django

unread,
May 25, 2021, 12:29:08 AM5/25/21
to django-...@googlegroups.com
#32780: Make covering and deferrable UniqueConstraint on SQLite a noop.

-------------------------------------+-------------------------------------
Reporter: Hannes Ljungberg | Owner: Hannes
Type: | Ljungberg
Cleanup/optimization | Status: assigned

Component: Migrations | Version: dev
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* needs_better_patch: 0 => 1
* type: Bug => Cleanup/optimization
* stage: Unreviewed => Accepted


Comment:

> stating that a constraint won't be created even though it is.

That's not true, a constraint won't be created. However I agree that
remaking table is not necessary and we can make it a noop. We can do the
same for deferrable unique constraints.

--
Ticket URL: <https://code.djangoproject.com/ticket/32780#comment:2>

Django

unread,
May 25, 2021, 3:24:55 AM5/25/21
to django-...@googlegroups.com
#32780: Make covering and deferrable UniqueConstraint on SQLite a noop.
-------------------------------------+-------------------------------------
Reporter: Hannes Ljungberg | Owner: Hannes
Type: | Ljungberg
Cleanup/optimization | Status: assigned
Component: Migrations | Version: dev
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Hannes Ljungberg):

> That's not true, a constraint won't be created. However I agree that
remaking table is not necessary and we can make it a noop. We can do the
same for deferrable unique constraints.

Ah! I just assumed that the table would be recreated with the constraint.
Thanks for clearing that up!

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

Django

unread,
May 25, 2021, 5:35:04 AM5/25/21
to django-...@googlegroups.com
#32780: Make covering and deferrable UniqueConstraint on SQLite a noop.
-------------------------------------+-------------------------------------
Reporter: Hannes Ljungberg | Owner: Hannes
Type: | Ljungberg
Cleanup/optimization | Status: closed
Component: Migrations | Version: dev
Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by GitHub <noreply@…>):

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


Comment:

In [changeset:"3e0fdf5546b8e172c87f255d55c6ddbe7d69f365" 3e0fdf5]:
{{{
#!CommitTicketReference repository=""
revision="3e0fdf5546b8e172c87f255d55c6ddbe7d69f365"
Fixed #32780 -- Made Add/RemoveConstraint operations a noop for
covering/deferrable unique constraints on SQLite.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/32780#comment:4>

Reply all
Reply to author
Forward
0 new messages