WIP: looking into double-charset problems
This commit is contained in:
parent
8b4a32cedd
commit
c6df7aa016
@ -152,6 +152,10 @@ 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.Charset != "" && column.Charset == mappedColumn.Charset {
|
||||
this.migrationContext.SharedColumns.SetCharsetUnchanged(column.Name)
|
||||
this.migrationContext.MappedSharedColumns.SetCharsetUnchanged(column.Name)
|
||||
}
|
||||
}
|
||||
|
||||
for _, column := range this.migrationContext.UniqueKey.Columns.Columns() {
|
||||
|
@ -38,6 +38,12 @@ func buildColumnsPreparedValues(columns *ColumnList) []string {
|
||||
var token string
|
||||
if column.timezoneConversion != nil {
|
||||
token = fmt.Sprintf("convert_tz(?, '%s', '%s')", column.timezoneConversion.ToTimezone, "+00:00")
|
||||
} else if column.CharsetUnchanged {
|
||||
token = "?"
|
||||
// token = fmt.Sprintf("BINARY ?")
|
||||
//token = fmt.Sprintf("_%s ?", column.Charset)
|
||||
// token = fmt.Sprintf("convert(? using %s)", column.Charset)
|
||||
// token = fmt.Sprintf("convert(?, char character set %s)", column.Charset)
|
||||
} else {
|
||||
token = "?"
|
||||
}
|
||||
|
@ -10,6 +10,8 @@ import (
|
||||
"reflect"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/outbrain/golib/log"
|
||||
)
|
||||
|
||||
type ColumnType int
|
||||
@ -29,15 +31,23 @@ type Column struct {
|
||||
Name string
|
||||
IsUnsigned bool
|
||||
Charset string
|
||||
CharsetUnchanged bool
|
||||
Type ColumnType
|
||||
timezoneConversion *TimezoneConvertion
|
||||
}
|
||||
|
||||
func (this *Column) convertArg(arg interface{}) interface{} {
|
||||
if s, ok := arg.(string); ok {
|
||||
if this.CharsetUnchanged {
|
||||
log.Errorf("============== charset unchanged for %+v: %+v, <%+v>", this.Name, this.Charset, arg)
|
||||
// return []byte(s)
|
||||
//return s
|
||||
}
|
||||
log.Errorf("============== charset for %+v: %+v, <%+v>", this.Name, this.Charset, arg)
|
||||
// string, charset conversion
|
||||
if encoding, ok := charsetEncodingMap[this.Charset]; ok {
|
||||
arg, _ = encoding.NewDecoder().String(s)
|
||||
log.Errorf("============== charset converted for %+v: %+v, <%+v>", this.Name, this.Charset, arg)
|
||||
}
|
||||
return arg
|
||||
}
|
||||
@ -142,6 +152,10 @@ func (this *ColumnList) IsUnsigned(columnName string) bool {
|
||||
return this.GetColumn(columnName).IsUnsigned
|
||||
}
|
||||
|
||||
func (this *ColumnList) SetCharsetUnchanged(columnName string) {
|
||||
this.GetColumn(columnName).CharsetUnchanged = true
|
||||
}
|
||||
|
||||
func (this *ColumnList) SetCharset(columnName string, charset string) {
|
||||
this.GetColumn(columnName).Charset = charset
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user