#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.
--
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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/047.c5d06bacd2ec507c8e2cdf5bf1e3e22d%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.