File tree 1 file changed +5
-11
lines changed 1 file changed +5
-11
lines changed Original file line number Diff line number Diff line change @@ -38,22 +38,16 @@ func CreateSchema(modelType reflect.Type) *Schema {
38
38
return s
39
39
}
40
40
func MakeSchema (modelType reflect.Type ) ([]string , []string , map [string ]FieldDB ) {
41
- numField := 0
42
- if modelType .Kind () == reflect .Ptr {
43
- numField = modelType .Elem ().NumField ()
44
- } else {
45
- numField = modelType .NumField ()
41
+ m := modelType
42
+ if m .Kind () == reflect .Ptr {
43
+ m = m .Elem ()
46
44
}
45
+ numField := m .NumField ()
47
46
columns := make ([]string , 0 )
48
47
keys := make ([]string , 0 )
49
48
schema := make (map [string ]FieldDB , 0 )
50
49
for idx := 0 ; idx < numField ; idx ++ {
51
- var field reflect.StructField
52
- if modelType .Kind () == reflect .Ptr {
53
- field = modelType .Elem ().Field (idx )
54
- } else {
55
- field = modelType .Field (idx )
56
- }
50
+ field := m .Field (idx )
57
51
tag , _ := field .Tag .Lookup ("gorm" )
58
52
if ! strings .Contains (tag , IgnoreReadWrite ) {
59
53
update := ! strings .Contains (tag , "update:false" )
You can’t perform that action at this time.
0 commit comments