summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorDhruvaPatil98 <dhruvapatil98@gmail.com>2022-06-23 12:32:41 +0530
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2022-06-23 11:12:35 +0200
commitc627226d05dd52aef59447dcfb29cec2c2b11b8a (patch)
treef469407374607a8cc090fcab3f51fccc7f470f22 /tests
parente6f36ea0a97af5c7d18bd155a6c4a937cf658ce6 (diff)
Fixed #33799, Refs #31685 -- Added parameters for updating conflicts to QuerySeta.abulk_create().
Diffstat (limited to 'tests')
-rw-r--r--tests/async_queryset/tests.py18
1 files changed, 17 insertions, 1 deletions
diff --git a/tests/async_queryset/tests.py b/tests/async_queryset/tests.py
index 792797fb9d..1b6dddce1f 100644
--- a/tests/async_queryset/tests.py
+++ b/tests/async_queryset/tests.py
@@ -6,7 +6,7 @@ from asgiref.sync import async_to_sync, sync_to_async
from django.db import NotSupportedError, connection
from django.db.models import Sum
-from django.test import TestCase, skipUnlessDBFeature
+from django.test import TestCase, skipIfDBFeature, skipUnlessDBFeature
from .models import SimpleModel
@@ -111,6 +111,22 @@ class AsyncQuerySetTest(TestCase):
qs = await SimpleModel.objects.abulk_create(instances)
self.assertEqual(len(qs), 10)
+ @skipUnlessDBFeature("has_bulk_insert", "supports_update_conflicts")
+ @skipIfDBFeature("supports_update_conflicts_with_target")
+ @async_to_sync
+ async def test_update_conflicts_unique_field_unsupported(self):
+ msg = (
+ "This database backend does not support updating conflicts with specifying "
+ "unique fields that can trigger the upsert."
+ )
+ with self.assertRaisesMessage(NotSupportedError, msg):
+ await SimpleModel.objects.abulk_create(
+ [SimpleModel(field=1), SimpleModel(field=2)],
+ update_conflicts=True,
+ update_fields=["field"],
+ unique_fields=["created"],
+ )
+
async def test_abulk_update(self):
instances = SimpleModel.objects.all()
async for instance in instances: