Skip to content

Commit

Permalink
fix: ignore case for type equivalence
Browse files Browse the repository at this point in the history
  • Loading branch information
bevzzz committed Oct 27, 2024
1 parent 3cfd8c6 commit c3253a5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
6 changes: 3 additions & 3 deletions dialect/pgdialect/sqltype.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,12 +126,12 @@ var (
)

func (d *Dialect) EquivalentType(col1, col2 sqlschema.Column) bool {
if col1.SQLType == col2.SQLType {
typ1, typ2 := strings.ToUpper(col1.SQLType), strings.ToUpper(col2.SQLType)

if typ1 == typ2 {
return checkVarcharLen(col1, col2, d.DefaultVarcharLen())
}

typ1, typ2 := strings.ToUpper(col1.SQLType), strings.ToUpper(col2.SQLType)

switch {
case char.IsAlias(typ1) && char.IsAlias(typ2):
return checkVarcharLen(col1, col2, d.DefaultVarcharLen())
Expand Down
3 changes: 2 additions & 1 deletion dialect/pgdialect/sqltype_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ func TestInspectorDialect_EquivalentType(t *testing.T) {
typ1, typ2 string
want bool
}{
{"text", "text", true}, // identical types
{"text", "text", true}, // identical types
{"bigint", "BIGINT", true}, // case-insensitive

{sqltype.VarChar, pgTypeVarchar, true},
{sqltype.VarChar, pgTypeCharacterVarying, true},
Expand Down

0 comments on commit c3253a5

Please sign in to comment.