mirror of
				https://github.com/django/django.git
				synced 2025-10-31 09:41:08 +00:00 
			
		
		
		
	[1.9.x] Fixed #22705 -- Fixed QuerySet.bulk_create() on models without any fields on Oracle.
Fixed on other backends by134ca4d438. Thanks Mariusz Felisiak for the solution. Backport of7a5b7e35bffrom master
This commit is contained in:
		| @@ -267,6 +267,9 @@ WHEN (new.%(col_name)s IS NULL) | |||||||
|     def max_name_length(self): |     def max_name_length(self): | ||||||
|         return 30 |         return 30 | ||||||
|  |  | ||||||
|  |     def pk_default_value(self): | ||||||
|  |         return "NULL" | ||||||
|  |  | ||||||
|     def prep_for_iexact_query(self, x): |     def prep_for_iexact_query(self, x): | ||||||
|         return x |         return x | ||||||
|  |  | ||||||
|   | |||||||
| @@ -47,3 +47,7 @@ class State(models.Model): | |||||||
| class TwoFields(models.Model): | class TwoFields(models.Model): | ||||||
|     f1 = models.IntegerField(unique=True) |     f1 = models.IntegerField(unique=True) | ||||||
|     f2 = models.IntegerField(unique=True) |     f2 = models.IntegerField(unique=True) | ||||||
|  |  | ||||||
|  |  | ||||||
|  | class NoFields(models.Model): | ||||||
|  |     pass | ||||||
|   | |||||||
| @@ -10,8 +10,8 @@ from django.test import ( | |||||||
| ) | ) | ||||||
|  |  | ||||||
| from .models import ( | from .models import ( | ||||||
|     Country, Pizzeria, ProxyCountry, ProxyMultiCountry, ProxyMultiProxyCountry, |     Country, NoFields, Pizzeria, ProxyCountry, ProxyMultiCountry, | ||||||
|     ProxyProxyCountry, Restaurant, State, TwoFields, |     ProxyMultiProxyCountry, ProxyProxyCountry, Restaurant, State, TwoFields, | ||||||
| ) | ) | ||||||
|  |  | ||||||
|  |  | ||||||
| @@ -177,6 +177,10 @@ class BulkCreateTests(TestCase): | |||||||
|         TwoFields.objects.bulk_create(objs, len(objs)) |         TwoFields.objects.bulk_create(objs, len(objs)) | ||||||
|         self.assertEqual(TwoFields.objects.count(), 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') |     @skipUnlessDBFeature('has_bulk_insert') | ||||||
|     def test_explicit_batch_size_efficiency(self): |     def test_explicit_batch_size_efficiency(self): | ||||||
|         objs = [TwoFields(f1=i, f2=i) for i in range(0, 100)] |         objs = [TwoFields(f1=i, f2=i) for i in range(0, 100)] | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user