1
0
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:
bcail
2024-02-08 17:41:32 +00:00
committed by GitHub
parent 1b5338d03e
commit 9c5e382b98
3 changed files with 32 additions and 10 deletions

View File

@@ -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(), [])