mirror of
https://github.com/django/django.git
synced 2025-08-02 01:53:15 +00:00
Fixed #31301 -- Fixed crash of QuerySet.bulk_create() with mixed empty and set ForeignKeys to AutoFields on Oracle.
This commit is contained in:
parent
8b30360322
commit
a21f7b91db
3 changed files with 24 additions and 4 deletions
|
@ -9,9 +9,9 @@ from django.test import (
|
|||
)
|
||||
|
||||
from .models import (
|
||||
Country, NoFields, NullableFields, Pizzeria, ProxyCountry,
|
||||
ProxyMultiCountry, ProxyMultiProxyCountry, ProxyProxyCountry, Restaurant,
|
||||
State, TwoFields,
|
||||
BigAutoFieldModel, Country, NoFields, NullableFields, Pizzeria,
|
||||
ProxyCountry, ProxyMultiCountry, ProxyMultiProxyCountry, ProxyProxyCountry,
|
||||
Restaurant, SmallAutoFieldModel, State, TwoFields,
|
||||
)
|
||||
|
||||
|
||||
|
@ -234,10 +234,16 @@ class BulkCreateTests(TestCase):
|
|||
|
||||
@skipUnlessDBFeature('has_bulk_insert')
|
||||
def test_bulk_insert_nullable_fields(self):
|
||||
fk_to_auto_fields = {
|
||||
'auto_field': NoFields.objects.create(),
|
||||
'small_auto_field': SmallAutoFieldModel.objects.create(),
|
||||
'big_auto_field': BigAutoFieldModel.objects.create(),
|
||||
}
|
||||
# NULL can be mixed with other values in nullable fields
|
||||
nullable_fields = [field for field in NullableFields._meta.get_fields() if field.name != 'id']
|
||||
NullableFields.objects.bulk_create([
|
||||
NullableFields(**{field.name: None}) for field in nullable_fields
|
||||
NullableFields(**{**fk_to_auto_fields, field.name: None})
|
||||
for field in nullable_fields
|
||||
])
|
||||
self.assertEqual(NullableFields.objects.count(), len(nullable_fields))
|
||||
for field in nullable_fields:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue