chore: refactor (#1331)

master
Kevin Wan 3 years ago committed by GitHub
parent 171afaadb9
commit 1becaeb7be
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -633,4 +633,3 @@ func NewSyntaxLitContext(parser antlr.Parser, parent antlr.ParserRuleContext, in
return p
}

@ -7,7 +7,7 @@ import (
"github.com/zeromicro/ddl-parser/parser"
)
var commonMysqlDataTypeMap = map[int]string{
var commonMysqlDataTypeMapInt = map[int]string{
// For consistency, all integer types are converted to int64
// number
parser.Bool: "int64",
@ -53,7 +53,7 @@ var commonMysqlDataTypeMap = map[int]string{
parser.TinyBlob: "string",
}
var commonMysqlDataTypeMap2 = map[string]string{
var commonMysqlDataTypeMapString = map[string]string{
// For consistency, all integer types are converted to int64
// number
"bool": "int64",
@ -95,7 +95,7 @@ var commonMysqlDataTypeMap2 = map[string]string{
// ConvertDataType converts mysql column type into golang type
func ConvertDataType(dataBaseType int, isDefaultNull bool) (string, error) {
tp, ok := commonMysqlDataTypeMap[dataBaseType]
tp, ok := commonMysqlDataTypeMapInt[dataBaseType]
if !ok {
return "", fmt.Errorf("unsupported database type: %v", dataBaseType)
}
@ -105,7 +105,7 @@ func ConvertDataType(dataBaseType int, isDefaultNull bool) (string, error) {
// ConvertStringDataType converts mysql column type into golang type
func ConvertStringDataType(dataBaseType string, isDefaultNull bool) (string, error) {
tp, ok := commonMysqlDataTypeMap2[strings.ToLower(dataBaseType)]
tp, ok := commonMysqlDataTypeMapString[strings.ToLower(dataBaseType)]
if !ok {
return "", fmt.Errorf("unsupported database type: %s", dataBaseType)
}

Loading…
Cancel
Save