Opened 8 years ago
Last modified 8 years ago
#29320 closed Bug
No exception when an Annotation alias matches a ForeignKey attname — at Version 1
| Reported by: | Flávio Juvenal | Owned by: | Flávio Juvenal |
|---|---|---|---|
| Component: | Database layer (models, ORM) | Version: | dev |
| Severity: | Normal | Keywords: | |
| Cc: | Triage Stage: | Ready for checkin | |
| Has patch: | yes | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description (last modified by )
Looks like the solution for "#11256 Fail loudly and clearly when an Annotation alias matches a field name" doesn't consider foreign keys attnames, e.g. {{author_id}}.
Here's a failing test, add it to aggregation_regress/tests.py:
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'))
Note:
See TracTickets
for help on using tickets.