From 7a5b7e35bf2e219225b9f26d3dd3e34f26e83e9c Mon Sep 17 00:00:00 2001 From: Tim Graham Date: Thu, 8 Oct 2015 21:14:24 -0400 Subject: Fixed #22705 -- Fixed QuerySet.bulk_create() on models without any fields on Oracle. Fixed on other backends by 134ca4d438bd7cbe8f0f287a00d545f96fa04a01. Thanks Mariusz Felisiak for the solution. --- tests/bulk_create/models.py | 4 ++++ tests/bulk_create/tests.py | 8 ++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/bulk_create/models.py b/tests/bulk_create/models.py index 22d16e75e5..c302a70b1b 100644 --- a/tests/bulk_create/models.py +++ b/tests/bulk_create/models.py @@ -47,3 +47,7 @@ class State(models.Model): class TwoFields(models.Model): f1 = models.IntegerField(unique=True) f2 = models.IntegerField(unique=True) + + +class NoFields(models.Model): + pass diff --git a/tests/bulk_create/tests.py b/tests/bulk_create/tests.py index ce069504d0..f881a1dba0 100644 --- a/tests/bulk_create/tests.py +++ b/tests/bulk_create/tests.py @@ -10,8 +10,8 @@ from django.test import ( ) from .models import ( - Country, Pizzeria, ProxyCountry, ProxyMultiCountry, ProxyMultiProxyCountry, - ProxyProxyCountry, Restaurant, State, TwoFields, + Country, NoFields, Pizzeria, ProxyCountry, ProxyMultiCountry, + ProxyMultiProxyCountry, ProxyProxyCountry, Restaurant, State, TwoFields, ) @@ -177,6 +177,10 @@ class BulkCreateTests(TestCase): TwoFields.objects.bulk_create(objs, len(objs)) self.assertEqual(TwoFields.objects.count(), len(objs)) + def test_empty_model(self): + NoFields.objects.bulk_create([NoFields() for i in range(2)]) + self.assertEqual(NoFields.objects.count(), 2) + @skipUnlessDBFeature('has_bulk_insert') def test_explicit_batch_size_efficiency(self): objs = [TwoFields(f1=i, f2=i) for i in range(0, 100)] -- cgit v1.2.1