#1346 closed defect (fixed)
django-admin creates invalid m2m table if the related models have same primary key name
| Reported by: | Russell Keith-Magee | Owned by: | Russell Keith-Magee |
|---|---|---|---|
| Component: | Core (Management commands) | Version: | magic-removal |
| Severity: | normal | Keywords: | recursive m2m primary key |
| Cc: | Triage Stage: | Unreviewed | |
| Has patch: | no | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
Consider the following model
class Article(models.Model):
...
related = models.ManyToManyField("Article")
This model currently breaks magic-removal - the SQL created on install is invalid, because the m2m table for the many-to-many field has two columns named article_id. This is easy to cause if you recursively define a m2m relationship; you can probably get a similar problem if you use custom primary key names.
At the very least, this should be picked up as a validation error; ideally, we need a strategy for producing unique column names in the m2m table.
Change History (5)
comment:1 by , 20 years ago
comment:2 by , 20 years ago
comment:3 by , 20 years ago
comment:4 by , 20 years ago
| Resolution: | → fixed |
|---|---|
| Status: | new → closed |
comment:5 by , 20 years ago
Note:
See TracTickets
for help on using tickets.
(In [2380]) magic-removal: Refs #1346 -- Added unit tests for expected behaviour of self referential m2m fields.