Opened 16 years ago

Closed 15 years ago

Last modified 13 years ago

#11226 closed (fixed)

Name clashes in ManyToMany

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

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 16 years ago.
Sugested solution
11226-auto_m2m_table_fk_names_clash.diff (2.7 KB ) - added by Ramiro Morales 16 years ago.
Fix by pkoch plus a (simple) test as suggested by Russell
11226-r12343.diff (7.0 KB ) - added by Ramiro Morales 15 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)

by pkoch, 16 years ago

Attachment: m2m_name_clashes.diff added

Sugested solution

comment:1 by Russell Keith-Magee, 16 years ago

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.

by Ramiro Morales, 16 years ago

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

comment:2 by Ramiro Morales, 16 years ago

Needs tests: unset
Patch needs improvement: unset

comment:3 by pkoch, 15 years ago

What's blocking this ticket? Can I help?

by Ramiro Morales, 15 years ago

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 by Ramiro Morales, 15 years ago

milestone: 1.2

comment:5 by Russell Keith-Magee, 15 years ago

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 by Russell Keith-Magee, 15 years ago

(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 by Jacob, 13 years ago

milestone: 1.2

Milestone 1.2 deleted

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