diff --git a/django/db/backends/oracle/utils.py b/django/db/backends/oracle/utils.py index 38a2c71774..74ea0c2508 100644 --- a/django/db/backends/oracle/utils.py +++ b/django/db/backends/oracle/utils.py @@ -54,6 +54,7 @@ class Oracle_datetime(datetime.datetime): class BulkInsertMapper: BLOB = 'TO_BLOB(%s)' + CBLOB = 'TO_CLOB(%s)' DATE = 'TO_DATE(%s)' INTERVAL = 'CAST(%s as INTERVAL DAY(9) TO SECOND(6))' NUMBER = 'TO_NUMBER(%s)' @@ -73,5 +74,6 @@ class BulkInsertMapper: 'PositiveIntegerField': NUMBER, 'PositiveSmallIntegerField': NUMBER, 'SmallIntegerField': NUMBER, + 'TextField': CBLOB, 'TimeField': TIMESTAMP, } diff --git a/tests/bulk_create/tests.py b/tests/bulk_create/tests.py index 08c753a826..47aa7afcdc 100644 --- a/tests/bulk_create/tests.py +++ b/tests/bulk_create/tests.py @@ -49,6 +49,16 @@ class BulkCreateTests(TestCase): Country.objects.bulk_create([Country(description='Ж' * 3000)]) self.assertEqual(Country.objects.count(), 1) + @skipUnlessDBFeature('has_bulk_insert') + def test_long_and_short_text(self): + Country.objects.bulk_create([ + Country(description='a' * 4001), + Country(description='a'), + Country(description='Ж' * 2001), + Country(description='Ж'), + ]) + self.assertEqual(Country.objects.count(), 4) + def test_multi_table_inheritance_unsupported(self): expected_message = "Can't bulk create a multi-table inherited model" with self.assertRaisesMessage(ValueError, expected_message):