Code

Opened 5 years ago

Closed 4 years ago

Last modified 3 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 5 years ago.
Sugested solution
11226-auto_m2m_table_fk_names_clash.diff (2.7 KB) - added by ramiro 5 years ago.
Fix by pkoch plus a (simple) test as suggested by Russell
11226-r12343.diff (7.0 KB) - added by ramiro 4 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 5 years ago by pkoch

Sugested solution

comment:1 Changed 5 years ago by russellm

  • Needs documentation unset
  • Needs tests set
  • Patch needs improvement set
  • Triage Stage changed from Unreviewed to Accepted

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 5 years ago by ramiro

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

comment:2 Changed 5 years ago by ramiro

  • Needs tests unset
  • Patch needs improvement unset

comment:3 Changed 5 years ago by pkoch

What's blocking this ticket? Can I help?

Changed 4 years ago by ramiro

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 4 years ago by ramiro

  • milestone set to 1.2

comment:5 Changed 4 years ago by russellm

  • Resolution set to fixed
  • Status changed from new to closed

(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 4 years ago by russellm

(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 3 years ago by jacob

  • milestone 1.2 deleted

Milestone 1.2 deleted

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.