Skip to content

Commit

Permalink
chore: clean dead code
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkgos committed May 13, 2024
1 parent fccbdc8 commit f7d2ff9
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 26 deletions.
2 changes: 1 addition & 1 deletion codegen.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions go_type_well_known.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
14 changes: 0 additions & 14 deletions internal/insql/insqlx.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
6 changes: 0 additions & 6 deletions matcher/matcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -36,8 +35,3 @@ func PbType(comment string) string {
}
return ""
}

// TrimEnumValue 去除 @EnumValue[xxxx] 的数据
func TrimEnumValue(value string) string {
return strings.TrimSpace(reProtobufEnumValue.ReplaceAllString(value, ""))
}
5 changes: 0 additions & 5 deletions matcher/matcher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

0 comments on commit f7d2ff9

Please sign in to comment.