Supporting JSON types
This commit is contained in:
parent
a43796d5c5
commit
2174588ebf
@ -545,6 +545,11 @@ func (this *Inspector) applyColumnTypes(databaseName, tableName string, columnsL
|
|||||||
columnsList.GetColumn(columnName).Type = sql.DateTimeColumnType
|
columnsList.GetColumn(columnName).Type = sql.DateTimeColumnType
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if strings.Contains(columnType, "json") {
|
||||||
|
for _, columnsList := range columnsLists {
|
||||||
|
columnsList.GetColumn(columnName).Type = sql.JSONColumnType
|
||||||
|
}
|
||||||
|
}
|
||||||
if strings.HasPrefix(columnType, "enum") {
|
if strings.HasPrefix(columnType, "enum") {
|
||||||
for _, columnsList := range columnsLists {
|
for _, columnsList := range columnsLists {
|
||||||
columnsList.GetColumn(columnName).Type = sql.EnumColumnType
|
columnsList.GetColumn(columnName).Type = sql.EnumColumnType
|
||||||
|
@ -38,6 +38,8 @@ func buildColumnsPreparedValues(columns *ColumnList) []string {
|
|||||||
var token string
|
var token string
|
||||||
if column.timezoneConversion != nil {
|
if column.timezoneConversion != nil {
|
||||||
token = fmt.Sprintf("convert_tz(?, '%s', '%s')", column.timezoneConversion.ToTimezone, "+00:00")
|
token = fmt.Sprintf("convert_tz(?, '%s', '%s')", column.timezoneConversion.ToTimezone, "+00:00")
|
||||||
|
} else if column.Type == JSONColumnType {
|
||||||
|
token = "convert(? using utf8mb4)"
|
||||||
} else {
|
} else {
|
||||||
token = "?"
|
token = "?"
|
||||||
}
|
}
|
||||||
@ -106,6 +108,8 @@ func BuildSetPreparedClause(columns *ColumnList) (result string, err error) {
|
|||||||
var setToken string
|
var setToken string
|
||||||
if column.timezoneConversion != nil {
|
if column.timezoneConversion != nil {
|
||||||
setToken = fmt.Sprintf("%s=convert_tz(?, '%s', '%s')", EscapeName(column.Name), column.timezoneConversion.ToTimezone, "+00:00")
|
setToken = fmt.Sprintf("%s=convert_tz(?, '%s', '%s')", EscapeName(column.Name), column.timezoneConversion.ToTimezone, "+00:00")
|
||||||
|
} else if column.Type == JSONColumnType {
|
||||||
|
setToken = fmt.Sprintf("%s=convert(? using utf8mb4)", EscapeName(column.Name))
|
||||||
} else {
|
} else {
|
||||||
setToken = fmt.Sprintf("%s=?", EscapeName(column.Name))
|
setToken = fmt.Sprintf("%s=?", EscapeName(column.Name))
|
||||||
}
|
}
|
||||||
|
@ -20,6 +20,7 @@ const (
|
|||||||
DateTimeColumnType = iota
|
DateTimeColumnType = iota
|
||||||
EnumColumnType = iota
|
EnumColumnType = iota
|
||||||
MediumIntColumnType = iota
|
MediumIntColumnType = iota
|
||||||
|
JSONColumnType = iota
|
||||||
)
|
)
|
||||||
|
|
||||||
const maxMediumintUnsigned int32 = 16777215
|
const maxMediumintUnsigned int32 = 16777215
|
||||||
|
Loading…
Reference in New Issue
Block a user