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.
* 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>
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>
* stage: Unreviewed => Ready for checkin
--
Ticket URL: <https://code.djangoproject.com/ticket/29320#comment:3>
* 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>