diff options
| author | Simon Charette <charette.s@gmail.com> | 2025-04-29 13:42:26 -0400 |
|---|---|---|
| committer | Sarah Boyce <42296566+sarahboyce@users.noreply.github.com> | 2025-04-30 10:38:19 +0100 |
| commit | 8ef4e0bd423ac3764004c73c3d1098e7a51a2945 (patch) | |
| tree | 3d5cb330f4fa5aa44d447e519361d6dca8d37af4 /tests/update | |
| parent | 27ffccc96bc68cd726a12f45ddf48f96973e9dce (diff) | |
Fixed #36360 -- Fixed QuerySet.update() crash when referring annotations through values().
The issue was only manifesting itself when also filtering againt a related
model as that forces the usage of a subquery because SQLUpdateCompiler doesn't
support the UPDATE FROM syntax yet.
Regression in 65ad4ade74dc9208b9d686a451cd6045df0c9c3a.
Refs #28900.
Thanks Gav O'Connor for the detailed report.
Diffstat (limited to 'tests/update')
| -rw-r--r-- | tests/update/tests.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/tests/update/tests.py b/tests/update/tests.py index 6f9dc60bae..bb83440008 100644 --- a/tests/update/tests.py +++ b/tests/update/tests.py @@ -256,6 +256,13 @@ class AdvancedTests(TestCase): Bar.objects.annotate(abs_id=Abs("m2m_foo")).order_by("-abs_id").update(x=4) self.assertEqual(Bar.objects.get().x, 4) + def test_update_values_annotation(self): + RelatedPoint.objects.annotate(abs_id=Abs("id")).filter( + data__is_active=False + ).values("id", "abs_id").update(data=self.d0) + self.r1.refresh_from_db(fields=["data"]) + self.assertEqual(self.r1.data, self.d0) + def test_update_negated_f(self): DataPoint.objects.update(is_active=~F("is_active")) self.assertCountEqual( |
