mirror of
https://gitee.com/johng/gf
synced 2026-06-06 16:21:40 +08:00
feat: pgsql 字段类型 支持 数组类型 (#1881)
This commit is contained in:
@ -568,6 +568,7 @@ func generateStructFieldDefinition(field *gdb.TableField, in generateStructDefin
|
||||
t, _ := gregex.ReplaceString(`\(.+\)`, "", field.Type)
|
||||
t = gstr.Split(gstr.Trim(t), " ")[0]
|
||||
t = gstr.ToLower(t)
|
||||
|
||||
switch t {
|
||||
case "binary", "varbinary", "blob", "tinyblob", "mediumblob", "longblob":
|
||||
typeName = "[]byte"
|
||||
@ -585,7 +586,18 @@ func generateStructFieldDefinition(field *gdb.TableField, in generateStructDefin
|
||||
} else {
|
||||
typeName = "int64"
|
||||
}
|
||||
|
||||
case "_int2":
|
||||
if gstr.ContainsI(field.Type, "unsigned") {
|
||||
typeName = "[]uint"
|
||||
} else {
|
||||
typeName = "[]int"
|
||||
}
|
||||
case "_int4", "_int8":
|
||||
if gstr.ContainsI(field.Type, "unsigned") {
|
||||
typeName = "[]uint64"
|
||||
} else {
|
||||
typeName = "[]int64"
|
||||
}
|
||||
case "real":
|
||||
typeName = "float32"
|
||||
|
||||
|
||||
@ -153,7 +153,24 @@ func (c *Core) convertFieldValueToLocalValue(fieldValue interface{}, fieldType s
|
||||
gconv.Uint(gconv.String(fieldValue))
|
||||
}
|
||||
return gconv.Int(gconv.String(fieldValue))
|
||||
|
||||
case
|
||||
"_int2":
|
||||
if gstr.ContainsI(fieldType, "unsigned") {
|
||||
gconv.Uints(gconv.String(fieldValue))
|
||||
}
|
||||
return gconv.Ints(gstr.ReplaceByMap(gconv.String(fieldValue), map[string]string{
|
||||
"{": "[",
|
||||
"}": "]",
|
||||
}))
|
||||
case
|
||||
"_int4", "_int8":
|
||||
if gstr.ContainsI(fieldType, "unsigned") {
|
||||
gconv.Uint64(gconv.String(fieldValue))
|
||||
}
|
||||
return gconv.Int64s(gstr.ReplaceByMap(gconv.String(fieldValue), map[string]string{
|
||||
"{": "[",
|
||||
"}": "]",
|
||||
}))
|
||||
case
|
||||
"int8", // For pgsql, int8 = bigint.
|
||||
"big_int",
|
||||
|
||||
Reference in New Issue
Block a user