mirror of
https://github.com/zeromicro/go-zero.git
synced 2025-02-03 00:38:40 +08:00
fix(goctl): Fix issues (#2543)
* fix #2541 * fix #2432 * Fix review comment * foramt code * foramt code
This commit is contained in:
parent
bbadbe0175
commit
7c9ef3ca67
@ -77,6 +77,7 @@ var commonMysqlDataTypeMapString = map[string]string{
|
|||||||
// For consistency, all integer types are converted to int64
|
// For consistency, all integer types are converted to int64
|
||||||
// bool
|
// bool
|
||||||
"bool": "bool",
|
"bool": "bool",
|
||||||
|
"_bool": "pq.BoolArray",
|
||||||
"boolean": "bool",
|
"boolean": "bool",
|
||||||
// number
|
// number
|
||||||
"tinyint": "int64",
|
"tinyint": "int64",
|
||||||
@ -85,14 +86,20 @@ var commonMysqlDataTypeMapString = map[string]string{
|
|||||||
"int": "int64",
|
"int": "int64",
|
||||||
"int1": "int64",
|
"int1": "int64",
|
||||||
"int2": "int64",
|
"int2": "int64",
|
||||||
|
"_int2": "pq.Int64Array",
|
||||||
"int3": "int64",
|
"int3": "int64",
|
||||||
"int4": "int64",
|
"int4": "int64",
|
||||||
|
"_int4": "pq.Int64Array",
|
||||||
"int8": "int64",
|
"int8": "int64",
|
||||||
|
"_int8": "pq.Int64Array",
|
||||||
"integer": "int64",
|
"integer": "int64",
|
||||||
|
"_integer": "pq.Int64Array",
|
||||||
"bigint": "int64",
|
"bigint": "int64",
|
||||||
"float": "float64",
|
"float": "float64",
|
||||||
"float4": "float64",
|
"float4": "float64",
|
||||||
|
"_float4": "pq.Float64Array",
|
||||||
"float8": "float64",
|
"float8": "float64",
|
||||||
|
"_float8": "pq.Float64Array",
|
||||||
"double": "float64",
|
"double": "float64",
|
||||||
"decimal": "float64",
|
"decimal": "float64",
|
||||||
"dec": "float64",
|
"dec": "float64",
|
||||||
@ -111,14 +118,17 @@ var commonMysqlDataTypeMapString = map[string]string{
|
|||||||
"nvarchar": "string",
|
"nvarchar": "string",
|
||||||
"nchar": "string",
|
"nchar": "string",
|
||||||
"char": "string",
|
"char": "string",
|
||||||
|
"_char": "pq.StringArray",
|
||||||
"character": "string",
|
"character": "string",
|
||||||
"varchar": "string",
|
"varchar": "string",
|
||||||
|
"_varchar": "pq.StringArray",
|
||||||
"binary": "string",
|
"binary": "string",
|
||||||
"bytea": "string",
|
"bytea": "string",
|
||||||
"longvarbinary": "string",
|
"longvarbinary": "string",
|
||||||
"varbinary": "string",
|
"varbinary": "string",
|
||||||
"tinytext": "string",
|
"tinytext": "string",
|
||||||
"text": "string",
|
"text": "string",
|
||||||
|
"_text": "pq.StringArray",
|
||||||
"mediumtext": "string",
|
"mediumtext": "string",
|
||||||
"longtext": "string",
|
"longtext": "string",
|
||||||
"enum": "string",
|
"enum": "string",
|
||||||
@ -129,6 +139,7 @@ var commonMysqlDataTypeMapString = map[string]string{
|
|||||||
"longblob": "string",
|
"longblob": "string",
|
||||||
"mediumblob": "string",
|
"mediumblob": "string",
|
||||||
"tinyblob": "string",
|
"tinyblob": "string",
|
||||||
|
"ltree": "[]byte",
|
||||||
}
|
}
|
||||||
|
|
||||||
// ConvertDataType converts mysql column type into golang type
|
// ConvertDataType converts mysql column type into golang type
|
||||||
@ -148,6 +159,10 @@ func ConvertStringDataType(dataBaseType string, isDefaultNull, unsigned, strict
|
|||||||
return "", fmt.Errorf("unsupported database type: %s", dataBaseType)
|
return "", fmt.Errorf("unsupported database type: %s", dataBaseType)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if strings.HasPrefix(dataBaseType, "_") {
|
||||||
|
return tp, nil
|
||||||
|
}
|
||||||
|
|
||||||
return mayConvertNullType(tp, isDefaultNull, unsigned, strict), nil
|
return mayConvertNullType(tp, isDefaultNull, unsigned, strict), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,11 +10,16 @@ import (
|
|||||||
const ModelCustom = `package {{.pkg}}
|
const ModelCustom = `package {{.pkg}}
|
||||||
{{if .withCache}}
|
{{if .withCache}}
|
||||||
import (
|
import (
|
||||||
|
"github.com/lib/pq"
|
||||||
"github.com/zeromicro/go-zero/core/stores/cache"
|
"github.com/zeromicro/go-zero/core/stores/cache"
|
||||||
"github.com/zeromicro/go-zero/core/stores/sqlx"
|
"github.com/zeromicro/go-zero/core/stores/sqlx"
|
||||||
)
|
)
|
||||||
{{else}}
|
{{else}}
|
||||||
import "github.com/zeromicro/go-zero/core/stores/sqlx"
|
|
||||||
|
import (
|
||||||
|
"github.com/lib/pq"
|
||||||
|
"github.com/zeromicro/go-zero/core/stores/sqlx"
|
||||||
|
)
|
||||||
{{end}}
|
{{end}}
|
||||||
var _ {{.upperStartCamelObject}}Model = (*custom{{.upperStartCamelObject}}Model)(nil)
|
var _ {{.upperStartCamelObject}}Model = (*custom{{.upperStartCamelObject}}Model)(nil)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user