Opened 8 years ago

Closed 8 years ago

Last modified 5 years ago

#10647 closed (fixed)

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

Reported by: Pavel 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:

Description

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 Pavel Anossov 8 years ago.
patch
managedm2m_v2.diff (701 bytes) - added by jbronn 8 years ago.
Omit ManyToMany table creation only if both fields are managed.

Download all attachments as: .zip

Change History (8)

Changed 8 years ago by Pavel Anossov

Attachment: managedm2m.diff added

patch

comment:1 Changed 8 years ago by jbronn

milestone: 1.1
Owner: changed from nobody to jbronn
Triage Stage: UnreviewedAccepted

comment:2 Changed 8 years ago by jbronn

Triage Stage: AcceptedDesign decision needed

Changed 8 years ago by jbronn

Attachment: managedm2m_v2.diff added

Omit ManyToMany table creation only if both fields are managed.

comment:3 Changed 8 years ago by jbronn

Needs documentation: set
Owner: changed from jbronn to Jacob
Triage Stage: Design decision neededAccepted

comment:4 Changed 8 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 8 years ago by Jacob

Resolution: fixed
Status: newclosed

(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

Milestone 1.1 deleted

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