From d6a8e5f5e1129d78e6ad40c66c6282ab55be8b61 Mon Sep 17 00:00:00 2001 From: Natalia <124304+nessita@users.noreply.github.com> Date: Thu, 21 Aug 2025 09:43:25 -0300 Subject: [PATCH] Fixed failing bulk_create test raising IntegrityError when run in reverse. When running the `bulk_create` tests with Postgres settings and `--reverse`, the following IntegrityError was raised in bulk_create.tests.BulkCreateTransactionTests.test_objs_with_and_without_pk: django.db.utils.IntegrityError: duplicate key value violates unique constraint "bulk_create_country_pkey" DETAIL: Key (id)=(1) already exists. This branch fixes this by ensuring the ID is unique since DB sequences are not resetted between tests. --- tests/bulk_create/tests.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/bulk_create/tests.py b/tests/bulk_create/tests.py index 4fd9e6c7bf..8ab918fff5 100644 --- a/tests/bulk_create/tests.py +++ b/tests/bulk_create/tests.py @@ -901,7 +901,7 @@ class BulkCreateTransactionTests(TransactionTestCase): with self.assertNumQueries(4): Country.objects.bulk_create( [ - Country(id=1, name="France", iso_two_letter="FR"), + Country(id=10, name="France", iso_two_letter="FR"), Country(name="Canada", iso_two_letter="CA"), ] )