Fixed #36683 -- Added error message on QuerySet.update() following distinct(*fields).
Some checks failed
Linters / flake8 (push) Has been cancelled
Linters / isort (push) Has been cancelled
Linters / black (push) Has been cancelled
Tests / Windows, SQLite, Python 3.14 (push) Has been cancelled
Tests / JavaScript tests (push) Has been cancelled

This commit is contained in:
Matthew Shirley 2025-10-23 11:52:32 -07:00 committed by Jacob Walls
parent 3ff32c50d1
commit 4744e9939b
3 changed files with 9 additions and 0 deletions

View file

@ -178,3 +178,9 @@ class DistinctOnTests(TestCase):
.order_by("nAmEAlIaS")
)
self.assertSequenceEqual(qs, [self.p1_o1, self.p2_o1, self.p3_o1])
def test_disallowed_update_distinct_on(self):
qs = Staff.objects.distinct("organisation").order_by("organisation")
msg = "Cannot call update() after .distinct(*fields)."
with self.assertRaisesMessage(TypeError, msg):
qs.update(name="p4")