Skip to content

Commit b4b98e8

Browse files
committed
reject altering from or to BigAutoField
1 parent 3425709 commit b4b98e8

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

sql_server/pyodbc/schema.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from django.db.backends.base.schema import (
55
BaseDatabaseSchemaEditor, logger, _related_non_m2m_objects,
66
)
7-
from django.db.models.fields import AutoField
7+
from django.db.models.fields import AutoField, BigAutoField
88
from django.db.models.fields.related import ManyToManyField
99
from django.utils import six
1010
from django.utils.text import force_text
@@ -57,10 +57,11 @@ def _alter_field(self, model, old_field, new_field, old_type, new_type,
5757
old_db_params, new_db_params, strict=False):
5858
"""Actually perform a "physical" (non-ManyToMany) field update."""
5959

60-
# the backend doesn't support altering from/to AutoField
60+
# the backend doesn't support altering from/to (Big)AutoField
6161
# because of the limited capability of SQL Server to edit IDENTITY property
62-
if isinstance(old_field, AutoField) or isinstance(new_field, AutoField):
63-
raise NotImplementedError("the backend doesn't support altering from/to AutoField.")
62+
for t in (AutoField, BigAutoField):
63+
if isinstance(old_field, t) or isinstance(new_field, t):
64+
raise NotImplementedError("the backend doesn't support altering from/to %s." % t.__name__)
6465
# Drop any FK constraints, we'll remake them later
6566
fks_dropped = set()
6667
if old_field.remote_field and old_field.db_constraint:

0 commit comments

Comments
 (0)