Skip to content

Commit a47ed0b

Browse files
committed
Better type picking for text types
2 parents 841f067 + dff2d00 commit a47ed0b

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

sql/types/conversion.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -642,7 +642,7 @@ func GeneralizeTypes(a, b sql.Type) sql.Type {
642642
if b == Null {
643643
return a
644644
}
645-
645+
646646
if a == b {
647647
return a
648648
}
@@ -722,9 +722,14 @@ func GeneralizeTypes(a, b sql.Type) sql.Type {
722722
}
723723

724724
if IsText(a) && IsText(b) {
725-
return a
725+
sta := a.(sql.StringType)
726+
stb := b.(sql.StringType)
727+
if sta.Length() > stb.Length() {
728+
return a
729+
}
730+
return b
726731
}
727-
732+
728733
// TODO: decide if we want to make this VarChar to match MySQL, match VarChar length to max of two types
729734
return LongText
730735
}

0 commit comments

Comments
 (0)