#35991: Migrations crash on SQLite when renaming part of CompositePrimaryKey.
-------------------------------------+-------------------------------------
Reporter: Mariusz Felisiak | Type: Bug
Status: new | Component: Database
| layer (models, ORM)
Version: dev | Severity: Release
| blocker
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
I've created a sample project that tries to rename a column included in
`CompositePrimaryKey`. Unfortunately, it crashes:
{{{
$ python manage.py migrate test_one 0002
...
File "/django/db/backends/base/schema.py", line 509, in create_model
sql, params = self.table_sql(model)
^^^^^^^^^^^^^^^^^^^^^
File "/django/db/backends/base/schema.py", line 290, in table_sql
constraint_sqls.append(self._pk_constraint_sql(pk.columns))
^^^^^^^^^^
File "/django/utils/functional.py", line 47, in __get__
res = instance.__dict__[self.name] = self.func(instance)
^^^^^^^^^^^^^^^^^^^
File "/django/db/models/fields/composite.py", line 81, in columns
return tuple(field.column for field in self.fields)
^^^^^^^^^^^
File "/django/utils/functional.py", line 47, in __get__
res = instance.__dict__[self.name] = self.func(instance)
^^^^^^^^^^^^^^^^^^^
File "/django/db/models/fields/composite.py", line 77, in fields
return tuple(meta.get_field(field_name) for field_name in
self.field_names)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/django/db/models/fields/composite.py", line 77, in <genexpr>
return tuple(meta.get_field(field_name) for field_name in
self.field_names)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/django/db/models/options.py", line 685, in get_field
raise FieldDoesNotExist(
django.core.exceptions.FieldDoesNotExist: NewRelease has no field named
'name'
}}}
I've attached a sample project. I can prepare a patch in the coming days.
--
Ticket URL: <https://code.djangoproject.com/ticket/35991>
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 [email protected].
To view this discussion visit
https://groups.google.com/d/msgid/django-updates/01070193ad8a9859-15580c9b-779f-432b-a9c0-84f5d65309d8-000000%40eu-central-1.amazonses.com.