mirror of
https://github.com/django/django.git
synced 2025-11-20 11:36:04 +00:00
Fixed #36260 -- Made bulk_create() work with DB-generated primary keys.
Co-authored-by: Simon Charette <charette.s@gmail.com>
This commit is contained in:
parent
c75fbe8430
commit
77b4ecbd53
4 changed files with 21 additions and 6 deletions
|
|
@ -1,3 +1,4 @@
|
|||
from datetime import datetime
|
||||
from math import ceil
|
||||
from operator import attrgetter
|
||||
|
||||
|
|
@ -23,6 +24,7 @@ from .models import (
|
|||
BigAutoFieldModel,
|
||||
Country,
|
||||
DbDefaultModel,
|
||||
DbDefaultPrimaryKey,
|
||||
FieldsWithDbColumns,
|
||||
NoFields,
|
||||
NullableFields,
|
||||
|
|
@ -866,3 +868,8 @@ class BulkCreateTests(TestCase):
|
|||
ctx[0]["sql"].count(created_at_quoted_name),
|
||||
2 if connection.features.can_return_rows_from_bulk_insert else 1,
|
||||
)
|
||||
|
||||
@skipUnlessDBFeature("can_return_rows_from_bulk_insert")
|
||||
def test_db_default_primary_key(self):
|
||||
(obj,) = DbDefaultPrimaryKey.objects.bulk_create([DbDefaultPrimaryKey()])
|
||||
self.assertIsInstance(obj.id, datetime)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue