Skip to content

Commit

Permalink
Fix same type comparing (#261)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
0marq committed Mar 19, 2024
1 parent 1139318 commit dba70db
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion migrator.go
Expand Up @@ -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())
Expand Down

0 comments on commit dba70db

Please sign in to comment.