first attempt at setting enum-to-string right
Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
This commit is contained in:
parent
9bb2daaf15
commit
939b898ea9
@ -187,6 +187,9 @@ func (this *Inspector) inspectOriginalAndGhostTables() (err error) {
|
||||
if column.Name == mappedColumn.Name && column.Type == sql.DateTimeColumnType && mappedColumn.Type == sql.TimestampColumnType {
|
||||
this.migrationContext.MappedSharedColumns.SetConvertDatetimeToTimestamp(column.Name, this.migrationContext.ApplierTimeZone)
|
||||
}
|
||||
if column.Name == mappedColumn.Name && column.Type == sql.EnumColumnType && mappedColumn.Charset != "" {
|
||||
this.migrationContext.MappedSharedColumns.SetEnumToTextConversion(column.Name)
|
||||
}
|
||||
}
|
||||
|
||||
for _, column := range this.migrationContext.UniqueKey.Columns.Columns() {
|
||||
|
@ -108,6 +108,8 @@ func BuildSetPreparedClause(columns *ColumnList) (result string, err error) {
|
||||
var setToken string
|
||||
if column.timezoneConversion != nil {
|
||||
setToken = fmt.Sprintf("%s=convert_tz(?, '%s', '%s')", EscapeName(column.Name), column.timezoneConversion.ToTimezone, "+00:00")
|
||||
} else if column.enumToTextConversion {
|
||||
setToken = fmt.Sprintf("%s=concat('', ?)", EscapeName(column.Name))
|
||||
} else if column.Type == JSONColumnType {
|
||||
setToken = fmt.Sprintf("%s=convert(? using utf8mb4)", EscapeName(column.Name))
|
||||
} else {
|
||||
|
@ -36,6 +36,7 @@ type Column struct {
|
||||
Charset string
|
||||
Type ColumnType
|
||||
timezoneConversion *TimezoneConversion
|
||||
enumToTextConversion bool
|
||||
}
|
||||
|
||||
func (this *Column) convertArg(arg interface{}) interface{} {
|
||||
@ -179,6 +180,14 @@ func (this *ColumnList) HasTimezoneConversion(columnName string) bool {
|
||||
return this.GetColumn(columnName).timezoneConversion != nil
|
||||
}
|
||||
|
||||
func (this *ColumnList) SetEnumToTextConversion(columnName string) {
|
||||
this.GetColumn(columnName).enumToTextConversion = true
|
||||
}
|
||||
|
||||
func (this *ColumnList) IsEnumToTextConversion(columnName string) bool {
|
||||
return this.GetColumn(columnName).enumToTextConversion
|
||||
}
|
||||
|
||||
func (this *ColumnList) String() string {
|
||||
return strings.Join(this.Names(), ",")
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user