Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#30800 closed Bug (fixed)

Altering field crashes for fields with custom db_type() on PostgreSQL.

Reported by: Mariusz Felisiak Owned by: Mariusz Felisiak
Component: Database layer (models, ORM) Version: 3.0
Severity: Release blocker Keywords:
Cc: Hasan Ramezani Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Altering field crashes for fields with a custom db_type() on PostgreSQL, e.g. ArrayField:

    def db_type(self, connection):
        size = self.size or ''
        return '%s[%s]' % (self.base_field.db_type(connection), size)

Regression in 1378d665a1c85897d951f2ca9618b848fdbba2e7.

  File "django/django/db/backends/postgresql/schema.py", line 72, in _alter_column_type_sql
    if self._field_data_type(old_field) != self._field_data_type(new_field):
  File "django/django/db/backends/postgresql/schema.py", line 45, in _field_data_type
    return self.connection.data_types[field.get_internal_type()]
KeyError: 'ArrayField'

Change History (3)

comment:1 by Mariusz Felisiak, 5 years ago

Has patch: set

comment:2 by GitHub <noreply@…>, 5 years ago

Resolution: fixed
Status: assignedclosed

In 580e644f:

Fixed #30800 -- Fixed migrations crash when altering a field with custom db_type().

Regression in 1378d665a1c85897d951f2ca9618b848fdbba2e7.

comment:3 by Mariusz Felisiak <felisiak.mariusz@…>, 5 years ago

In 1adf85d1:

[3.0.x] Fixed #30800 -- Fixed migrations crash when altering a field with custom db_type().

Regression in 1378d665a1c85897d951f2ca9618b848fdbba2e7.
Backport of 580e644f24f1c5ae5b94784fb73a9953a178fd26 from master

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