Skip to content

Running django-admin migrate command fails due KeyError: 'nulls_distinct' #108

@trebor74hr

Description

@trebor74hr

Django version is: 5.0.11
ibm_db_django version is 1.5.3.0

Running migration for django.contrib.auth application (0009 or 0010, e.g.: django-admin.py migrate auth 0009) I get error:

   ....
    schema_editor.alter_field(from_model, from_field, to_field)
  File "/srv/pyenv311/lib64/python3.11/site-packages/ibm_db_django/schemaEditor.py", line 287, in alter_field
    self._alter_field(model, old_field, new_field, old_type, new_type,
  File "/srv/pyenv311/lib64/python3.11/site-packages/ibm_db_django/schemaEditor.py", line 413, in _alter_field
    old_field, new_field = self.alterFieldDataTypeByRemaking(model, old_field, new_field, strict)
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/srv/pyenv311/lib64/python3.11/site-packages/ibm_db_django/schemaEditor.py", line 845, in alterFieldDataTypeByRemaking
    self.add_field_post(model, tmp_new_field, notnull, p_key, unique)
  File "/srv/pyenv311/lib64/python3.11/site-packages/ibm_db_django/schemaEditor.py", line 771, in add_field_post
    sql = self.sql_create_unique % {'table': self.quote_name(model._meta.db_table), 'name': constraint_name, 'columns': self.quote_name(field.column), 'deferrable': self._deferrable_constraint_sql(None)}
          ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
KeyError: 'nulls_distinct'

Quick workaround is:

771                 sql = self.sql_create_unique % {'table': self.quote_name(model._meta.db_table), 'name': constrai...
772                                 , "nulls_distinct": ""}

but the proper fix should supply some meaningful value.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions