﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
36301	select_for_update(of) crash when used with values_list since Django 5.2 on Postgres	Simon Charette	Simon Charette	"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:

{{{#!python
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

{{{#!diff
diff --git a/tests/select_for_update/tests.py b/tests/select_for_update/tests.py
index e8ba8f8b6e..18fca277cb 100644
--- a/tests/select_for_update/tests.py
+++ b/tests/select_for_update/tests.py
@@ -13,6 +13,8 @@ from django.db import (
     router,
     transaction,
 )
+from django.db.models import F, Value
+from django.db.models.functions import Concat
 from django.test import (
     TransactionTestCase,
     override_settings,
@@ -122,6 +124,17 @@ class SelectForUpdateTests(TransactionTestCase):
             list(Person.objects.select_for_update(no_key=True))
         self.assertIs(self.has_for_update_sql(ctx.captured_queries, no_key=True), True)
 
+    @skipUnlessDBFeature(""has_select_for_update_of"")
+    def test_for_update_of_values_list(self):
+        with transaction.atomic():
+            values = (
+                Person.objects.select_for_update(
+                    of=(""self"",),
+                )
+                .values_list(Concat(Value(""Dr. ""), F(""name"")), ""born"")
+            ).get(pk=self.person.pk)
+        self.assertTupleEqual(values, (""Dr. Reinhardt"", self.city1.pk))
+
     @skipUnlessDBFeature(""has_select_for_update_of"")
}}}

"	Bug	closed	Database layer (models, ORM)	5.2	Release blocker	fixed		OutOfFocus4 Sarah Boyce	Ready for checkin	1	0	0	0	0	0
