#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. -- You received this message because you are subscribed to the Google Groups "Django updates" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-updates+unsubscr...@googlegroups.com. To view this discussion visit https://groups.google.com/d/msgid/django-updates/01070197b3005920-5dea256c-c2e0-4b84-9cf6-a576257debe5-000000%40eu-central-1.amazonses.com.