Re: [Django] #34357: UniqueConstraint doesn't violate NULL values on SQLite. (was: UniqueConstraint not working with Sqlite3)

3 views
Skip to first unread message

Django

unread,
Feb 20, 2023, 11:25:08 PM2/20/23
to django-...@googlegroups.com
#34357: UniqueConstraint doesn't violate NULL values on SQLite.
-------------------------------------+-------------------------------------
Reporter: Conrad | Owner: nobody
Type: Bug | Status: closed
Component: Database layer | Version: 4.1
(models, ORM) |
Severity: Normal | Resolution: invalid
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* status: new => closed
* resolution: => invalid
* component: Uncategorized => Database layer (models, ORM)


Comment:

Thanks for the report. `NULL` doesn't violate unique constraints or cause
conflicts in most (all?) databases, that's why it's possible to add
multiple `NULL`-values. This is a database behavior, not something that
Django is responsible for. I'm not sure Django documentation is the right
place to document this. Closing as "invalid" unless someone strongly
believes we should document this.

> but if I understand ​https://stackoverflow.com/questions/15497985/how-
to-add-unique-constraint-to-existing-table-in-sqlite correctly it is not
really the right way of adding the constraint.

This is the right way to add unique partial constraint on SQLite.

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

Reply all
Reply to author
Forward
0 new messages