1
0
mirror of https://github.com/django/django.git synced 2025-10-23 21:59:11 +00:00

Fixed #32442 -- Used converters on returning fields from INSERT statements.

This commit is contained in:
Adam Johnson
2021-02-13 08:58:24 +00:00
committed by Mariusz Felisiak
parent 619f26d289
commit d9de74141e
4 changed files with 47 additions and 11 deletions

View File

@@ -1,7 +1,8 @@
from django.db import IntegrityError, transaction
from django.test import TestCase, skipIfDBFeature
from django.test import TestCase, skipIfDBFeature, skipUnlessDBFeature
from .models import Bar, Business, Employee, Foo
from .fields import MyWrapper
from .models import Bar, Business, CustomAutoFieldModel, Employee, Foo
class BasicCustomPKTests(TestCase):
@@ -230,3 +231,13 @@ class CustomPKTests(TestCase):
with self.assertRaises(IntegrityError):
with transaction.atomic():
Employee.objects.create(first_name="Tom", last_name="Smith")
def test_auto_field_subclass_create(self):
obj = CustomAutoFieldModel.objects.create()
self.assertIsInstance(obj.id, MyWrapper)
@skipUnlessDBFeature('can_return_rows_from_bulk_insert')
def test_auto_field_subclass_bulk_create(self):
obj = CustomAutoFieldModel()
CustomAutoFieldModel.objects.bulk_create([obj])
self.assertIsInstance(obj.id, MyWrapper)