Skip to content

Commit 1768047

Browse files
committed
fix failure on test_alter_int_pk_to_int_unique
1 parent 4b1b7c3 commit 1768047

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

sql_server/pyodbc/schema.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,9 @@ def _alter_field(self, model, old_field, new_field, old_type, new_type,
277277
for sql, params in post_actions:
278278
self.execute(sql, params)
279279
# Added a unique?
280-
if not old_field.unique and new_field.unique:
280+
if (not old_field.unique and new_field.unique) or (
281+
old_field.primary_key and not new_field.primary_key and new_field.unique
282+
):
281283
self.execute(self._create_unique_sql(model, [new_field.column]))
282284
# Added an index?
283285
# constraint will no longer be used in lieu of an index. The following

0 commit comments

Comments
 (0)