mirror of
https://github.com/django/django.git
synced 2025-10-28 08:06:09 +00:00
Fixed #35073 -- Avoided unnecessary calling of callables used by SET/SET_DEFAULT in Collector.collect().
This commit is contained in:
@@ -408,9 +408,17 @@ class SetQueryCountTests(TestCase):
|
||||
Item.objects.create(
|
||||
version=version,
|
||||
location=location,
|
||||
location_default=location,
|
||||
location_value=location,
|
||||
)
|
||||
# 3 UPDATEs for SET of item values and one for DELETE locations.
|
||||
with self.assertNumQueries(4):
|
||||
# 2 UPDATEs for SET of item values and one for DELETE locations.
|
||||
with self.assertNumQueries(3):
|
||||
location.delete()
|
||||
|
||||
|
||||
class SetCallableCollectorDefaultTests(TestCase):
|
||||
def test_set(self):
|
||||
# Collector doesn't call callables used by models.SET and
|
||||
# models.SET_DEFAULT if not necessary.
|
||||
Toy.objects.create(name="test")
|
||||
Toy.objects.all().delete()
|
||||
self.assertSequenceEqual(Toy.objects.all(), [])
|
||||
|
||||
Reference in New Issue
Block a user