#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 <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/062.9ca849637735accfafa43c6e6ce17ae5%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to