mirror of
https://github.com/django/django.git
synced 2025-10-23 21:59:11 +00:00
Fixed #24509 -- Added Expression support to SQLInsertCompiler
This commit is contained in:
@@ -3,6 +3,8 @@ from __future__ import unicode_literals
|
||||
from operator import attrgetter
|
||||
|
||||
from django.db import connection
|
||||
from django.db.models import Value
|
||||
from django.db.models.functions import Lower
|
||||
from django.test import (
|
||||
TestCase, override_settings, skipIfDBFeature, skipUnlessDBFeature,
|
||||
)
|
||||
@@ -183,3 +185,12 @@ class BulkCreateTests(TestCase):
|
||||
TwoFields.objects.all().delete()
|
||||
with self.assertNumQueries(1):
|
||||
TwoFields.objects.bulk_create(objs, len(objs))
|
||||
|
||||
@skipUnlessDBFeature('has_bulk_insert')
|
||||
def test_bulk_insert_expressions(self):
|
||||
Restaurant.objects.bulk_create([
|
||||
Restaurant(name="Sam's Shake Shack"),
|
||||
Restaurant(name=Lower(Value("Betty's Beetroot Bar")))
|
||||
])
|
||||
bbb = Restaurant.objects.filter(name="betty's beetroot bar")
|
||||
self.assertEqual(bbb.count(), 1)
|
||||
|
||||
Reference in New Issue
Block a user