Re: [Django] #35453: ManyToMany field incorrectly identified as a concrete field on the defining side.

12 views
Skip to first unread message

Django

unread,
Jun 27, 2025, 4:07:20 PMJun 27
to django-...@googlegroups.com
#35453: ManyToMany field incorrectly identified as a concrete field on the defining
side.
-------------------------------------+-------------------------------------
Reporter: Harro | Owner: nobody
Type: Bug | Status: new
Component: Database layer | Version: 5.0
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Simon Charette):

FWIW the only tests failing when applying

{{{#!diff
diff --git a/django/db/models/fields/related.py
b/django/db/models/fields/related.py
index bad71a5fd6..fdb4e47700 100644
--- a/django/db/models/fields/related.py
+++ b/django/db/models/fields/related.py
@@ -2062,3 +2062,7 @@ def db_type(self, connection):

def db_parameters(self, connection):
return {"type": None, "check": None}
+
+ def get_attname_column(self):
+ attname, column = super().get_attname_column()
+ return attname, None
}}}

Are `migrations` related one mainly because we skip non-concrete fields
alterations (see `_field_should_be_altered`) which can be further
addressed by

{{{#!diff
diff --git a/django/db/backends/base/schema.py
b/django/db/backends/base/schema.py
index cf9243ccf0..5057013c0e 100644
--- a/django/db/backends/base/schema.py
+++ b/django/db/backends/base/schema.py
@@ -204,6 +204,8 @@ def execute(self, sql, params=()):
cursor.execute(sql, params)

def quote_name(self, name):
+ if name is None:
+ return name
return self.connection.ops.quote_name(name)

def table_sql(self, model):
@@ -1655,7 +1657,11 @@ def _field_indexes_sql(self, model, field):
return output

def _field_should_be_altered(self, old_field, new_field,
ignore=None):
- if not old_field.concrete and not new_field.concrete:
+ if not (
+ old_field.concrete or old_field.is_relation and
old_field.many_to_many
+ ) and not (
+ new_field.concrete or new_field.is_relation and
new_field.many_to_many
+ ):
return False
ignore = ignore or set()
_, old_path, old_args, old_kwargs = old_field.deconstruct()
}}}

I think it's worth discussing what we want to do with non-concrete field
alterations in general as it has some implications with composite foreign
key support as we'll most likely have to make such foreign keys non-
concrete as discussed ticket:35956#comment:13.
--
Ticket URL: <https://code.djangoproject.com/ticket/35453#comment:7>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Jul 14, 2025, 9:29:29 AMJul 14
to django-...@googlegroups.com
#35453: ManyToMany field incorrectly identified as a concrete field on the defining
side.
-------------------------------------+-------------------------------------
Reporter: Harro | Owner: nobody
Type: Bug | Status: new
Component: Database layer | Version: 5.0
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Sarah Boyce):

* stage: Unreviewed => Accepted

--
Ticket URL: <https://code.djangoproject.com/ticket/35453#comment:8>

Django

unread,
Aug 3, 2025, 5:10:12 PMAug 3
to django-...@googlegroups.com
#35453: ManyToMany field incorrectly identified as a concrete field on the defining
side.
-------------------------------------+-------------------------------------
Reporter: Harro | Owner: Jason
| Hall
Type: Bug | Status: assigned
Component: Database layer | Version: 5.0
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Jason Hall):

* owner: nobody => Jason Hall
* status: new => assigned

--
Ticket URL: <https://code.djangoproject.com/ticket/35453#comment:9>

Django

unread,
Aug 3, 2025, 6:56:31 PMAug 3
to django-...@googlegroups.com
#35453: ManyToMany field incorrectly identified as a concrete field on the defining
side.
-------------------------------------+-------------------------------------
Reporter: Harro | Owner: Jason
| Hall
Type: Bug | Status: assigned
Component: Database layer | Version: 5.0
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Jason Hall):

* has_patch: 0 => 1

--
Ticket URL: <https://code.djangoproject.com/ticket/35453#comment:10>

Django

unread,
Sep 18, 2025, 11:41:44 AM (3 days ago) Sep 18
to django-...@googlegroups.com
#35453: ManyToMany field incorrectly identified as a concrete field on the defining
side.
-------------------------------------+-------------------------------------
Reporter: Harro | Owner: (none)
Type: Bug | Status: new
Component: Database layer | Version: 5.0
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Jason Hall):

* owner: Jason Hall => (none)
* status: assigned => new

--
Ticket URL: <https://code.djangoproject.com/ticket/35453#comment:11>

Django

unread,
Sep 19, 2025, 3:58:07 AM (3 days ago) Sep 19
to django-...@googlegroups.com
#35453: ManyToMany field incorrectly identified as a concrete field on the defining
side.
-------------------------------------+-------------------------------------
Reporter: Harro | Owner: Ryan P
| Kilby
Type: Bug | Status: assigned
Component: Database layer | Version: 5.0
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Sarah Boyce):

* owner: (none) => Ryan P Kilby
* status: new => assigned

--
Ticket URL: <https://code.djangoproject.com/ticket/35453#comment:12>

Django

unread,
Sep 19, 2025, 11:54:55 AM (2 days ago) Sep 19
to django-...@googlegroups.com
#35453: ManyToMany field incorrectly identified as a concrete field on the defining
side.
-------------------------------------+-------------------------------------
Reporter: Harro | Owner: Ryan P
| Kilby
Type: Bug | Status: assigned
Component: Database layer | Version: 5.0
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Jacob Walls):

* stage: Accepted => Ready for checkin

--
Ticket URL: <https://code.djangoproject.com/ticket/35453#comment:13>
Reply all
Reply to author
Forward
0 new messages