#36301 closed Bug (fixed)
select_for_update(of) crash when used with values_list since Django 5.2 on Postgres
Description ¶
This was extracted from #36299 as a distinct issue.
Queryset evaluation raises an AttributeError
if the database backend supports SELECT ... FOR UPDATE
. The following code:
with atomic(): values = ( User.objects.select_for_update(of=("self",)) .values_list( Concat(F("first_name"), Value(" "), F("last_name")), "email" ) .get(pk=12) )
will fail with a stacktrace ending in AttributeError: 'Concat' object has no attribute 'target'
using the Postgresql DB backend.
Replicate by Sarah as a regression in 65ad4ade74dc9208b9d686a451cd6045df0c9c3a
-
TabularUnified tests/select_for_update/tests.py
diff --git a/tests/select_for_update/tests.py b/tests/select_for_update/tests.py index e8ba8f8b6e..18fca277cb 100644
a b from django.db import ( 13 13 router, 14 14 transaction, 15 15 ) 16 from django.db.models import F, Value 17 from django.db.models.functions import Concat 16 18 from django.test import ( 17 19 TransactionTestCase, 18 20 override_settings, … … class SelectForUpdateTests(TransactionTestCase): 122 124 list(Person.objects.select_for_update(no_key=True)) 123 125 self.assertIs(self.has_for_update_sql(ctx.captured_queries, no_key=True), True) 124 126 127 @skipUnlessDBFeature("has_select_for_update_of") 128 def test_for_update_of_values_list(self): 129 with transaction.atomic(): 130 values = ( 131 Person.objects.select_for_update( 132 of=("self",), 133 ) 134 .values_list(Concat(Value("Dr. "), F("name")), "born") 135 ).get(pk=self.person.pk) 136 self.assertTupleEqual(values, ("Dr. Reinhardt", self.city1.pk)) 137 125 138 @skipUnlessDBFeature("has_select_for_update_of")
Change History (5)
comment:1 by , 7 days ago
Triage Stage: | Unreviewed → Accepted |
---|
comment:3 by , 4 days ago
Triage Stage: | Accepted → Ready for checkin |
---|
Note:
See TracTickets
for help on using tickets.
Self-accepting since #36299 was accepted once the regression was identified.