[Django] #29320: No exception when an Annotation alias matches a ForeignKey attname

2 views
Skip to first unread message

Django

unread,
Apr 12, 2018, 2:04:17 PM4/12/18
to django-...@googlegroups.com
#29320: No exception when an Annotation alias matches a ForeignKey attname
-------------------------------------+-------------------------------------
Reporter: Flávio | Owner: Flávio Juvenal
Juvenal |
Type: Bug | Status: assigned
Component: Database | Version: master
layer (models, ORM) |
Severity: Normal | Keywords:
Triage Stage: | Has patch: 1
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
Looks like the solution for "#11256 Fail loudly and clearly when an
Annotation alias matches a field name" doesn't consider foreign keys
{{{attname}}}s, e.g. {{author_id}}.

Here's a failing test, add it to aggregation_regress/tests.py:
{{{
#!python
def test_fk_id_name_conflict(self):
msg = "The annotation 'contact_id' conflicts with a field on the
model."
with self.assertRaisesMessage(ValueError, msg):
Book.objects.annotate(contact_id=F('publisher_id'))
}}}

I'll make a PR soon.

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

Django

unread,
Apr 12, 2018, 2:10:41 PM4/12/18
to django-...@googlegroups.com
#29320: No exception when an Annotation alias matches a ForeignKey attname
-------------------------------------+-------------------------------------
Reporter: Flávio Juvenal | Owner: Flávio

| Juvenal
Type: Bug | Status: assigned
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Flávio Juvenal):

* owner: Flávio Juvenal => Flávio Juvenal


Old description:

> Looks like the solution for "#11256 Fail loudly and clearly when an
> Annotation alias matches a field name" doesn't consider foreign keys
> {{{attname}}}s, e.g. {{author_id}}.
>
> Here's a failing test, add it to aggregation_regress/tests.py:
> {{{
> #!python
> def test_fk_id_name_conflict(self):
> msg = "The annotation 'contact_id' conflicts with a field on the
> model."
> with self.assertRaisesMessage(ValueError, msg):
> Book.objects.annotate(contact_id=F('publisher_id'))
> }}}
>
> I'll make a PR soon.

New description:

Looks like the solution for "#11256 Fail loudly and clearly when an
Annotation alias matches a field name" doesn't consider foreign keys
{{{attname}}}s, e.g. {{author_id}}.

Here's a failing test, add it to aggregation_regress/tests.py:
{{{
#!python

def test_fk_attname_conflict(self):


msg = "The annotation 'contact_id' conflicts with a field on the
model."
with self.assertRaisesMessage(ValueError, msg):
Book.objects.annotate(contact_id=F('publisher_id'))
}}}

PR here: https://github.com/django/django/pull/9873/files

--

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

Django

unread,
Apr 12, 2018, 2:15:36 PM4/12/18
to django-...@googlegroups.com
#29320: No exception when an Annotation alias matches a ForeignKey attname
-------------------------------------+-------------------------------------
Reporter: Flávio Juvenal | Owner: Flávio

| Juvenal
Type: Bug | Status: assigned
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Description changed by Flávio Juvenal:

Old description:

> Looks like the solution for "#11256 Fail loudly and clearly when an
> Annotation alias matches a field name" doesn't consider foreign keys
> {{{attname}}}s, e.g. {{author_id}}.
>
> Here's a failing test, add it to aggregation_regress/tests.py:
> {{{
> #!python

> def test_fk_attname_conflict(self):


> msg = "The annotation 'contact_id' conflicts with a field on the
> model."
> with self.assertRaisesMessage(ValueError, msg):
> Book.objects.annotate(contact_id=F('publisher_id'))
> }}}
>

> PR here: https://github.com/django/django/pull/9873/files

New description:

Looks like the solution for "#11256 Fail loudly and clearly when an
Annotation alias matches a field name" doesn't consider foreign keys
{{{attname}}}s, e.g. {{{author_id}}}.

Here's a failing test, add it to aggregation_regress/tests.py:
{{{
#!python

def test_fk_attname_conflict(self):


msg = "The annotation 'contact_id' conflicts with a field on the
model."
with self.assertRaisesMessage(ValueError, msg):
Book.objects.annotate(contact_id=F('publisher_id'))
}}}

PR here: https://github.com/django/django/pull/9873/files

--

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

Django

unread,
Apr 12, 2018, 9:16:57 PM4/12/18
to django-...@googlegroups.com
#29320: Add an exception when an annotation alias matches a ForeignKey attname
-------------------------------------+-------------------------------------
Reporter: Flávio Juvenal | Owner: Flávio

| Juvenal
Type: Bug | Status: assigned
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | 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 Tim Graham):

* stage: Unreviewed => Ready for checkin


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

Django

unread,
Apr 12, 2018, 9:36:32 PM4/12/18
to django-...@googlegroups.com
#29320: Add an exception when an annotation alias matches a ForeignKey attname
-------------------------------------+-------------------------------------

Reporter: Flávio Juvenal | Owner: Flávio
| Juvenal
Type: Bug | Status: closed

Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | 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 Tim Graham <timograham@…>):

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


Comment:

In [changeset:"e1f13f15512ece2d8ea8c7bf9f704ce4286c2ffa" e1f13f15]:
{{{
#!CommitTicketReference repository=""
revision="e1f13f15512ece2d8ea8c7bf9f704ce4286c2ffa"
Fixed #29320 -- Added an exception when an annotation alias matches a
ForeignKey attname.
}}}

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

Reply all
Reply to author
Forward
0 new messages