[Django] #34226: The local_setter may use a wrong f

15 views
Skip to first unread message

Django

unread,
Dec 23, 2022, 2:50:43 AM12/23/22
to django-...@googlegroups.com
#34226: The local_setter may use a wrong f
-----------------------------------------+------------------------
Reporter: zhu | Owner: nobody
Type: Uncategorized | Status: new
Component: Uncategorized | Version: 4.1
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-----------------------------------------+------------------------
https://github.com/django/django/commit/e1ae2b00504ba30481285b2bd767d1ad561bf4be
https://github.com/django/django/blob/0bd2c0c9015b53c41394a1c0989afbfd94dc2830/django/db/models/sql/compiler.py#L1290
should use partial, just like the remote_setter

--
Ticket URL: <https://code.djangoproject.com/ticket/34226>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Dec 23, 2022, 2:55:15 AM12/23/22
to django-...@googlegroups.com
#34226: The local_setter may use a wrong f
-------------------------------------+-------------------------------------
Reporter: zhu | Owner: nobody
Type: Uncategorized | Status: closed
Component: Database layer | Version: 4.1
(models, ORM) |
Severity: Normal | Resolution: needsinfo

Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* status: new => closed
* resolution: => needsinfo
* component: Uncategorized => Database layer (models, ORM)


Comment:

Replying to [ticket:34226 zhu]:


> should use partial, just like the remote_setter

Why? it doesn't use a `name` values from the loop. I don't think you've
explained the issue.

--
Ticket URL: <https://code.djangoproject.com/ticket/34226#comment:1>

Django

unread,
Dec 23, 2022, 2:57:20 AM12/23/22
to django-...@googlegroups.com
#34226: The local_setter may use a wrong f
-------------------------------------+-------------------------------------
Reporter: zhu | Owner: nobody
Type: Uncategorized | Status: closed
Component: Database layer | Version: 4.1
(models, ORM) |
Severity: Normal | Resolution: needsinfo
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Mariusz Felisiak):

Replying to [comment:1 Mariusz Felisiak]:

> Why? it doesn't use a `name` values from the loop. I don't think you've
explained the issue.

Ahh, OK, it uses `f`. Can you provide a regression test?

--
Ticket URL: <https://code.djangoproject.com/ticket/34226#comment:2>

Django

unread,
Dec 23, 2022, 2:58:46 AM12/23/22
to django-...@googlegroups.com
#34226: The local_setter may use a wrong f
-------------------------------------+-------------------------------------
Reporter: zhu | Owner: nobody
Type: Bug | Status: closed

Component: Database layer | Version: 4.1
(models, ORM) |
Severity: Normal | Resolution: needsinfo
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* type: Uncategorized => Bug


--
Ticket URL: <https://code.djangoproject.com/ticket/34226#comment:3>

Django

unread,
Dec 23, 2022, 4:25:02 AM12/23/22
to django-...@googlegroups.com
#34226: The local_setter may use a wrong f
-------------------------------------+-------------------------------------
Reporter: zhu | Owner: nobody
Type: Bug | Status: new

Component: Database layer | Version: 4.1
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* cc: Simon Charette, Hasan Ramezani (added)
* status: closed => new
* resolution: needsinfo =>
* stage: Unreviewed => Accepted


--
Ticket URL: <https://code.djangoproject.com/ticket/34226#comment:4>

Django

unread,
Dec 23, 2022, 4:51:55 AM12/23/22
to django-...@googlegroups.com
#34226: The local_setter may use a wrong f
-------------------------------------+-------------------------------------
Reporter: zhu | Owner: nobody
Type: Bug | Status: new
Component: Database layer | Version: 4.1
(models, ORM) |
Severity: Normal | 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 zhu):

Replying to [comment:2 Mariusz Felisiak]:


> Replying to [comment:1 Mariusz Felisiak]:
>
> > Why? it doesn't use a `name` values from the loop. I don't think
you've explained the issue.
>
> Ahh, OK, it uses `f`. Can you provide a regression test?

{{{#!python
# models.py
from django.db import models

class Pool(models.Model):
name = models.CharField(max_length=30)


class AnotherPoolStyle(models.Model):
name = models.CharField(max_length=30)
pool1 = models.OneToOneField(Pool, models.CASCADE,
related_name='style_from_pool1')
pool2 = models.OneToOneField(Pool, models.CASCADE,
related_name='style_from_pool2')

# tests.py
from django.test import TestCase

from django.db.models import FilteredRelation

class Tests(TestCase):
@classmethod
def setUpTestData(cls):
cls.p1 = Pool.objects.create(name="pool1")
cls.p2 = Pool.objects.create(name="pool2")
cls.ap = AnotherPoolStyle.objects.create(
name="Another Pool Style",
pool1=cls.p1,
pool2=cls.p2,
)

def test_filtered_relation_select_related(self):
with self.assertNumQueries(1):
ps = list(AnotherPoolStyle.objects.annotate(
p1=FilteredRelation('pool1'),
p2=FilteredRelation('pool2'),
).select_related('p1', 'p2'))
self.assertIs(ps[0], ps[0].p1.style_from_pool1) # failed
self.assertIs(ps[0], ps[0].p2.style_from_pool2)


}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/34226#comment:5>

Reply all
Reply to author
Forward
0 new messages