Opened 8 years ago

Closed 7 years ago

Last modified 5 years ago

#11226 closed (fixed)

Name clashes in ManyToMany

Reported by: pkoch Owned by: nobody
Component: Database layer (models, ORM) Version: master
Severity: Keywords: ManyToMany name clash
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

When both sides of a ManyToMany relation are of different classes and have the same object_name, a clash occours.

To reproduce:

  • Create two apps, legacy and next_gen,
  • Create a Model with the same name on both,
  • Create a ManyToMany between them, and
  • Run manage.py syncdb

My first take on a solution is in the attached patch.

Attachments (3)

m2m_name_clashes.diff (1.4 KB) - added by pkoch 8 years ago.
Sugested solution
11226-auto_m2m_table_fk_names_clash.diff (2.7 KB) - added by Ramiro Morales 8 years ago.
Fix by pkoch plus a (simple) test as suggested by Russell
11226-r12343.diff (7.0 KB) - added by Ramiro Morales 7 years ago.
Patch updated to current trunk. Includes tests, fixes a related validation that was wrongly being triggered and a couple of docstrings typo fixes.

Download all attachments as: .zip

Change History (10)

Changed 8 years ago by pkoch

Attachment: m2m_name_clashes.diff added

Sugested solution

comment:1 Changed 8 years ago by Russell Keith-Magee

Needs tests: set
Patch needs improvement: set
Triage Stage: UnreviewedAccepted

Interesting edge case. However, patch needs tests - I would suggest the m2m_regress regression test defining a User model with an m2m to contrib.auth.User.

Changed 8 years ago by Ramiro Morales

Fix by pkoch plus a (simple) test as suggested by Russell

comment:2 Changed 8 years ago by Ramiro Morales

Needs tests: unset
Patch needs improvement: unset

comment:3 Changed 7 years ago by pkoch

What's blocking this ticket? Can I help?

Changed 7 years ago by Ramiro Morales

Attachment: 11226-r12343.diff added

Patch updated to current trunk. Includes tests, fixes a related validation that was wrongly being triggered and a couple of docstrings typo fixes.

comment:4 Changed 7 years ago by Ramiro Morales

milestone: 1.2

comment:5 Changed 7 years ago by Russell Keith-Magee

Resolution: fixed
Status: newclosed

(In [12489]) Fixed #11226 -- Corrected an validation edge case with m2m relations between two models with the same class name. Thanks to pkoch for the report, and to Ramiro Morales for the patch.

comment:6 Changed 7 years ago by Russell Keith-Magee

(In [12596]) [1.1.X] Fixed #11226 -- Corrected an validation edge case with m2m relations between two models with the same class name. Thanks to pkoch for the report, and to Ramiro Morales for the patch.

Backport of r12489 from trunk.

comment:7 Changed 5 years ago by Jacob

milestone: 1.2

Milestone 1.2 deleted

Note: See TracTickets for help on using tickets.
Back to Top