Re: [Django] #36299: Calling alias after values_list adds the aliased value to the result set

14 views
Skip to first unread message

Django

unread,
Apr 4, 2025, 10:22:17 AM4/4/25
to django-...@googlegroups.com
#36299: Calling alias after values_list adds the aliased value to the result set
-------------------------------------+-------------------------------------
Reporter: OutOfFocus4 | Owner: Simon
| Charette
Type: Bug | Status: assigned
Component: Database layer | Version: 5.2
(models, ORM) |
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Sarah Boyce):

Replicated the second issue, also 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")
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/36299#comment:4>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Apr 4, 2025, 12:39:48 PM4/4/25
to django-...@googlegroups.com
#36299: Calling alias after values_list adds the aliased value to the result set
-------------------------------------+-------------------------------------
Reporter: OutOfFocus4 | Owner: Simon
| Charette
Type: Bug | Status: assigned
Component: Database layer | Version: 5.2
(models, ORM) |
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Simon Charette):

Thanks for the triage Sarah, I'll create a ticket for the second one.

Here's [https://github.com/django/django/pull/19342 a PR] for the alias
issue Jeff. I gave you co-author attribute since you pointed at the exact
solution and provided tests but I can remove it if you'd prefer just LMK
on Github.
--
Ticket URL: <https://code.djangoproject.com/ticket/36299#comment:5>

Django

unread,
Apr 4, 2025, 12:39:58 PM4/4/25
to django-...@googlegroups.com
#36299: Calling alias after values_list adds the aliased value to the result set
-------------------------------------+-------------------------------------
Reporter: OutOfFocus4 | Owner: Simon
| Charette
Type: Bug | Status: assigned
Component: Database layer | Version: 5.2
(models, ORM) |
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Simon Charette):

* has_patch: 0 => 1

--
Ticket URL: <https://code.djangoproject.com/ticket/36299#comment:6>

Django

unread,
Apr 4, 2025, 12:46:12 PM4/4/25
to django-...@googlegroups.com
#36299: Calling alias after values_list adds the aliased value to the result set
-------------------------------------+-------------------------------------
Reporter: OutOfFocus4 | Owner: Simon
| Charette
Type: Bug | Status: assigned
Component: Database layer | Version: 5.2
(models, ORM) |
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Simon Charette):

Moved the `select_for_update` issue to #36301.
--
Ticket URL: <https://code.djangoproject.com/ticket/36299#comment:7>

Django

unread,
Apr 5, 2025, 1:50:10 PM4/5/25
to django-...@googlegroups.com
#36299: Calling alias after values_list adds the aliased value to the result set
-------------------------------------+-------------------------------------
Reporter: OutOfFocus4 | Owner: Simon
| Charette
Type: Bug | Status: assigned
Component: Database layer | Version: 5.2
(models, ORM) |
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* stage: Accepted => Ready for checkin

--
Ticket URL: <https://code.djangoproject.com/ticket/36299#comment:8>

Django

unread,
Apr 5, 2025, 3:37:54 PM4/5/25
to django-...@googlegroups.com
#36299: Calling alias after values_list adds the aliased value to the result set
-------------------------------------+-------------------------------------
Reporter: OutOfFocus4 | Owner: Simon
| Charette
Type: Bug | Status: closed
Component: Database layer | Version: 5.2
(models, ORM) |
Severity: Release blocker | Resolution: fixed
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak <felisiak.mariusz@…>):

* resolution: => fixed
* status: assigned => closed

Comment:

In [changeset:"12b771a1ec4bbfe82405176f5601e6441855a303" 12b771a1]:
{{{#!CommitTicketReference repository=""
revision="12b771a1ec4bbfe82405176f5601e6441855a303"
Fixed #36299 -- Prevented field selection on QuerySet.alias() after
values().

Regression in 65ad4ade74dc9208b9d686a451cd6045df0c9c3a.

Refs #28900.

Thanks Jeff Iadarola for the report and tests.

Co-Authored-By: OutOfFocus4 <jeff.i...@gmail.com>
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/36299#comment:9>

Django

unread,
Apr 5, 2025, 3:38:45 PM4/5/25
to django-...@googlegroups.com
#36299: Calling alias after values_list adds the aliased value to the result set
-------------------------------------+-------------------------------------
Reporter: OutOfFocus4 | Owner: Simon
| Charette
Type: Bug | Status: closed
Component: Database layer | Version: 5.2
(models, ORM) |
Severity: Release blocker | Resolution: fixed
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Mariusz Felisiak <felisiak.mariusz@…>):

In [changeset:"cd1aa54f5a1ad8673f8852aa3b0022c06b154b79" cd1aa54f]:
{{{#!CommitTicketReference repository=""
revision="cd1aa54f5a1ad8673f8852aa3b0022c06b154b79"
[5.2.x] Fixed #36299 -- Prevented field selection on QuerySet.alias()
after values().

Regression in 65ad4ade74dc9208b9d686a451cd6045df0c9c3a.

Refs #28900.

Thanks Jeff Iadarola for the report and tests.

Co-Authored-By: OutOfFocus4 <jeff.i...@gmail.com>

Backport of 12b771a1ec4bbfe82405176f5601e6441855a303 from main
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/36299#comment:10>
Reply all
Reply to author
Forward
0 new messages