fixed bug
This commit is contained in:
parent
bb8c5c04d7
commit
54473a3e45
20
engine.go
20
engine.go
|
@ -967,23 +967,18 @@ func (engine *Engine) mapType(v reflect.Value) *core.Table {
|
|||
continue
|
||||
}
|
||||
if strings.ToUpper(tags[0]) == "EXTENDS" {
|
||||
if fieldValue.Kind() == reflect.Struct {
|
||||
parentTable := engine.mapType(fieldValue)
|
||||
for _, col := range parentTable.Columns() {
|
||||
col.FieldName = fmt.Sprintf("%v.%v", t.Field(i).Name, col.FieldName)
|
||||
table.AddColumn(col)
|
||||
}
|
||||
|
||||
continue
|
||||
} else if fieldValue.Kind() == reflect.Ptr {
|
||||
switch fieldValue.Kind() {
|
||||
case reflect.Ptr:
|
||||
f := fieldValue.Type().Elem()
|
||||
if f.Kind() == reflect.Struct {
|
||||
fieldPtr := fieldValue
|
||||
fieldValue = fieldValue.Elem()
|
||||
if !fieldValue.IsValid() || fieldValue.IsNil() {
|
||||
if !fieldValue.IsValid() || fieldPtr.IsNil() {
|
||||
fieldValue = reflect.New(f).Elem()
|
||||
}
|
||||
}
|
||||
|
||||
fallthrough
|
||||
case reflect.Struct:
|
||||
parentTable := engine.mapType(fieldValue)
|
||||
for _, col := range parentTable.Columns() {
|
||||
col.FieldName = fmt.Sprintf("%v.%v", t.Field(i).Name, col.FieldName)
|
||||
|
@ -991,8 +986,9 @@ func (engine *Engine) mapType(v reflect.Value) *core.Table {
|
|||
}
|
||||
|
||||
continue
|
||||
default:
|
||||
//TODO: warning
|
||||
}
|
||||
//TODO: warning
|
||||
}
|
||||
|
||||
indexNames := make(map[string]int)
|
||||
|
|
Loading…
Reference in New Issue