Re: [Django] #34225: bulk_create() raises IntegrityError when another constraint exists on set of fields. (was: django 4.1.x - bulk_create - django.db.utils.IntegrityError: duplicate key value violates unique constraint)

6 views
Skip to first unread message

Django

unread,
Dec 22, 2022, 1:58:23 PM12/22/22
to django-...@googlegroups.com
#34225: bulk_create() raises IntegrityError when another constraint exists on set
of fields.
-------------------------------------+-------------------------------------
Reporter: Victor J. Fuente | Owner: nobody
Type: Bug | Status: closed
Component: Database layer | Version: 4.1
(models, ORM) |
Severity: Normal | Resolution: invalid
Keywords: #bulk_create | 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


Comment:

Thanks for the report, however Django is not at fault. `NULL` values don't
violate unique constraints so set of unique fields passed to the `ON
CONFLICT(...)` is not violated i.e. the `test_unique` constraint. The
second constraint (`test_coal_unique`) is violated but it's not taken into
account by `ON CONFLICT` statement. If you're having trouble understanding
how this statement is evaluated by your database, see
TicketClosingReasons/UseSupportChannels for ways to get help.

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

Reply all
Reply to author
Forward
0 new messages