diff --git a/codegen.go b/codegen.go index 564d0d4..5fc4274 100644 --- a/codegen.go +++ b/codegen.go @@ -189,7 +189,7 @@ func (field *FieldDescriptor) fixField(allFieldName, escapeFieldNames map[string field.Type = IntType().WithNewType(field.Type.Type) } if field.Nullable && opt.DisableNullToPoint { - gt, ok := sqlNullValueGoType[field.Type.Type] + gt, ok := getSQLNullValueGoType(field.Type.Type) if ok { field.Type = gt field.GoPointer = false diff --git a/go_type_well_known.go b/go_type_well_known.go index ee7322a..08e3103 100644 --- a/go_type_well_known.go +++ b/go_type_well_known.go @@ -55,6 +55,11 @@ var sqlNullValueGoType = map[Type]GoType{ TypeTime: sqlNullTimeType, } +func getSQLNullValueGoType(t Type) (GoType, bool) { + v, ok := sqlNullValueGoType[t] + return v, ok +} + func BoolType() GoType { return boolType } func IntType() GoType { return intType } func Int8Type() GoType { return int8Type } diff --git a/internal/insql/insqlx.go b/internal/insql/insqlx.go index caffc8d..850a61e 100644 --- a/internal/insql/insqlx.go +++ b/internal/insql/insqlx.go @@ -62,20 +62,6 @@ func Collation(elements []schema.Attr) (string, bool) { return val.V, ok } -// DefaultValue returns the string represents the DEFAULT of a column. -func DefaultValue(c *schema.Column) (string, bool) { - switch x := schema.UnderlyingExpr(c.Default).(type) { - case nil: - return "", false - case *schema.Literal: - return x.V, true - case *schema.RawExpr: - return x.X, true - default: - panic(fmt.Sprintf("unexpected default value type: %T", x)) - } -} - func IndexEqual(idx1, idx2 *schema.Index) bool { return idx1 != nil && idx2 != nil && (idx1 == idx2 || idx1.Name == idx2.Name) } diff --git a/matcher/matcher.go b/matcher/matcher.go index 59aa964..abb41ff 100644 --- a/matcher/matcher.go +++ b/matcher/matcher.go @@ -8,7 +8,6 @@ import ( var reJSONTag = regexp.MustCompile(`^.*\[@(?i:jsontag):\s*([^\[\]]*)\].*`) var reAffixJSONTag = regexp.MustCompile(`^.*\[@(affix)\s*\].*`) var reProtobufType = regexp.MustCompile(`^.*\[@(?i:pbtype):\s*([^\[\]]*)\].*`) -var reProtobufEnumValue = regexp.MustCompile(`@EnumValue\[[^\]]*\]`) // JsonTag 匹配json标签 // [@jsontag:id,omitempty] @@ -36,8 +35,3 @@ func PbType(comment string) string { } return "" } - -// TrimEnumValue 去除 @EnumValue[xxxx] 的数据 -func TrimEnumValue(value string) string { - return strings.TrimSpace(reProtobufEnumValue.ReplaceAllString(value, "")) -} diff --git a/matcher/matcher_test.go b/matcher/matcher_test.go index 407d392..4312b5a 100644 --- a/matcher/matcher_test.go +++ b/matcher/matcher_test.go @@ -125,8 +125,3 @@ func Test_ProtobufType(t *testing.T) { }) } } - -func Test_TrimEnumValue(t *testing.T) { - a := TrimEnumValue("some text@EnumValue[1:a,2:哈哈]") - t.Log(a) -}