From dba70dbfa63b806b32fc0e27c43f8f7953690336 Mon Sep 17 00:00:00 2001 From: 0marq <45561584+0marq@users.noreply.github.com> Date: Tue, 19 Mar 2024 03:45:10 +0100 Subject: [PATCH] Fix same type comparing (#261) * Fix same type comparing `fieldColumnType.DatabaseTypeName()` returns non capitalized string, while `fileType.SQL` returns capitalized string. This commit aims to fix this and avoid detecting a type change when the type did not change. * Use strings.EqualFold to compare types --- migrator.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/migrator.go b/migrator.go index 6174e1c..4044e58 100644 --- a/migrator.go +++ b/migrator.go @@ -312,7 +312,7 @@ func (m Migrator) AlterColumn(value interface{}, field string) error { fileType := clause.Expr{SQL: m.DataTypeOf(field)} // check for typeName and SQL name isSameType := true - if fieldColumnType.DatabaseTypeName() != fileType.SQL { + if strings.EqualFold(fieldColumnType.DatabaseTypeName(), fileType.SQL) { isSameType = false // if different, also check for aliases aliases := m.GetTypeAliases(fieldColumnType.DatabaseTypeName())