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
|
continue
|
||||||
}
|
}
|
||||||
if strings.ToUpper(tags[0]) == "EXTENDS" {
|
if strings.ToUpper(tags[0]) == "EXTENDS" {
|
||||||
if fieldValue.Kind() == reflect.Struct {
|
switch fieldValue.Kind() {
|
||||||
parentTable := engine.mapType(fieldValue)
|
case reflect.Ptr:
|
||||||
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 {
|
|
||||||
f := fieldValue.Type().Elem()
|
f := fieldValue.Type().Elem()
|
||||||
if f.Kind() == reflect.Struct {
|
if f.Kind() == reflect.Struct {
|
||||||
|
fieldPtr := fieldValue
|
||||||
fieldValue = fieldValue.Elem()
|
fieldValue = fieldValue.Elem()
|
||||||
if !fieldValue.IsValid() || fieldValue.IsNil() {
|
if !fieldValue.IsValid() || fieldPtr.IsNil() {
|
||||||
fieldValue = reflect.New(f).Elem()
|
fieldValue = reflect.New(f).Elem()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
fallthrough
|
||||||
|
case reflect.Struct:
|
||||||
parentTable := engine.mapType(fieldValue)
|
parentTable := engine.mapType(fieldValue)
|
||||||
for _, col := range parentTable.Columns() {
|
for _, col := range parentTable.Columns() {
|
||||||
col.FieldName = fmt.Sprintf("%v.%v", t.Field(i).Name, col.FieldName)
|
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
|
continue
|
||||||
|
default:
|
||||||
|
//TODO: warning
|
||||||
}
|
}
|
||||||
//TODO: warning
|
|
||||||
}
|
}
|
||||||
|
|
||||||
indexNames := make(map[string]int)
|
indexNames := make(map[string]int)
|
||||||
|
|
Loading…
Reference in New Issue