Opened 7 years ago

Closed 7 years ago

Last modified 5 years ago

#10647 closed (fixed)

Many-to-many tables are created even with managed=False

Reported by: Anossov Owned by: jacob
Component: Database layer (models, ORM) Version: master
Severity: Keywords: managed, manytomany
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: yes
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:


What else can I say..
django.db.backends.creation.sql_for_many_to_many has no guards whatsoever.

    def sql_for_many_to_many(self, model, style):
        "Return the CREATE TABLE statments for all the many-to-many tables defined on a model"
        output = []
        for f in model._meta.local_many_to_many:
            output.extend(self.sql_for_many_to_many_field(model, f, style))
        return output

Attachments (2)

managedm2m.diff (594 bytes) - added by Anossov 7 years ago.
managedm2m_v2.diff (701 bytes) - added by jbronn 7 years ago.
Omit ManyToMany table creation only if both fields are managed.

Download all attachments as: .zip

Change History (8)

Changed 7 years ago by Anossov


comment:1 Changed 7 years ago by jbronn

  • milestone set to 1.1
  • Needs documentation unset
  • Needs tests unset
  • Owner changed from nobody to jbronn
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

comment:2 Changed 7 years ago by jbronn

  • Triage Stage changed from Accepted to Design decision needed

Changed 7 years ago by jbronn

Omit ManyToMany table creation only if both fields are managed.

comment:3 Changed 7 years ago by jbronn

  • Needs documentation set
  • Owner changed from jbronn to jacob
  • Triage Stage changed from Design decision needed to Accepted

comment:4 Changed 7 years ago by jbronn

"In the face of ambiguity refuse the temptation to guess." In other words, we should only explicitly omit creation if both are unmanaged.

comment:5 Changed 7 years ago by jacob

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

(In [10455]) Fixed #10647: intermediary tables between two umanaged models are no longer created.

comment:6 Changed 5 years ago by jacob

  • milestone 1.1 deleted

Milestone 1.1 deleted

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