Opened 5 years ago

Closed 5 years ago

#24236 closed Bug (fixed)

Custom ManyToManyFields don't generate SQL database changes

Reported by: Markus Holtermann Owned by: Markus Holtermann
Component: Database layer (models, ORM) Version: 1.7
Severity: Release blocker Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Andriy Sokolovskiy)

Regression introduced in 3d4a826174b7a411a03be39725e60c940944a7fe

If user writes a class, inherited from ManyToManyField ("custom" m2m field) and doesn't define a get_internal_type(): return "ManyToManyField the schema backends won't recognize it as a m2m field and thus don't treat it as such.

This breaks existing code.

Change History (11)

comment:1 Changed 5 years ago by Andriy Sokolovskiy

Description: modified (diff)

comment:2 Changed 5 years ago by Markus Holtermann

Has patch: set
Type: UncategorizedBug

comment:3 Changed 5 years ago by Andriy Sokolovskiy

Maybe bug is not here.
Related fields are not explicitly define the internal type. As I can see, non-related fields define it explicitly. (for example, https://github.com/django/django/blob/0f3ea8c0bc9c7f7f5e448b0b2137bc6351f5eae3/django/db/models/fields/__init__.py#L1785)

comment:4 Changed 5 years ago by Tim Graham

Triage Stage: UnreviewedAccepted

comment:5 Changed 5 years ago by Markus Holtermann

See also the discussion on the django- developers mailing list: https://groups.google.com/d/msg/django-developers/-zQL0skuPh0/zUHWeAph6yAJ

comment:6 Changed 5 years ago by Tim Graham

Needs documentation: set

comment:7 Changed 5 years ago by Markus Holtermann

Needs documentation: unset

comment:8 Changed 5 years ago by Markus Holtermann

Status: newassigned

comment:9 Changed 5 years ago by Tim Graham

Triage Stage: AcceptedReady for checkin

comment:10 Changed 5 years ago by Markus Holtermann <info@…>

In 37b50db09230f90827008cc8404675d8b4876c10:

[1.7.x] Refs #24236 -- Added regression test for 3d4a826174b7a411a03be39725e60c940944a7fe

Thanks irc user ris for the report

comment:11 Changed 5 years ago by Markus Holtermann <info@…>

Resolution: fixed
Status: assignedclosed

In f8c040e1676506e3bcba5f2744199fdcde430552:

[1.7.x] Fixed #24236 -- Treated inherited m2m fields as such if they don't define get_internal_type()

Regression introduced in 3d4a826174b7a411a03be39725e60c940944a7fe

Thanks IRC user ris for the report, Loïc Bistuer, Anssi Kääriäinen and
Andriy Sokolovskiy for the discussion and Tim Graham for the review.

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