mirror of
https://gitee.com/johng/gf
synced 2026-06-06 16:21:40 +08:00
@ -407,7 +407,7 @@ func doMapConvertForMapOrStructValue(in doMapConvertForMapOrStructValueInput) in
|
||||
array[arrayIndex] = doMapConvertForMapOrStructValue(
|
||||
doMapConvertForMapOrStructValueInput{
|
||||
IsRoot: false,
|
||||
Value: rvAttrField.Index(arrayIndex),
|
||||
Value: rvAttrField.Index(arrayIndex).Interface(),
|
||||
RecursiveType: in.RecursiveType,
|
||||
RecursiveOption: in.RecursiveType == recursiveTypeTrue,
|
||||
Tags: in.Tags,
|
||||
@ -463,7 +463,7 @@ func doMapConvertForMapOrStructValue(in doMapConvertForMapOrStructValueInput) in
|
||||
for i := 0; i < length; i++ {
|
||||
array[i] = doMapConvertForMapOrStructValue(doMapConvertForMapOrStructValueInput{
|
||||
IsRoot: false,
|
||||
Value: reflectValue.Index(i),
|
||||
Value: reflectValue.Index(i).Interface(),
|
||||
RecursiveType: in.RecursiveType,
|
||||
RecursiveOption: in.RecursiveType == recursiveTypeTrue,
|
||||
Tags: in.Tags,
|
||||
|
||||
@ -223,3 +223,43 @@ func Test_Issue2381(t *testing.T) {
|
||||
t.Assert(a1.Flag.String(), a2.Flag.String())
|
||||
})
|
||||
}
|
||||
|
||||
// https://github.com/gogf/gf/issues/2391
|
||||
func Test_Issue2391(t *testing.T) {
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
type Inherit struct {
|
||||
Ids []int
|
||||
Ids2 []int64
|
||||
Flag *gjson.Json
|
||||
Title string
|
||||
}
|
||||
|
||||
type Test1 struct {
|
||||
Inherit
|
||||
}
|
||||
type Test2 struct {
|
||||
Inherit
|
||||
}
|
||||
|
||||
var (
|
||||
a1 Test1
|
||||
a2 Test2
|
||||
)
|
||||
|
||||
a1 = Test1{
|
||||
Inherit{
|
||||
Ids: []int{1, 2, 3},
|
||||
Ids2: []int64{4, 5, 6},
|
||||
Flag: gjson.New("[\"1\", \"2\"]"),
|
||||
Title: "测试",
|
||||
},
|
||||
}
|
||||
|
||||
err := gconv.Scan(a1, &a2)
|
||||
t.AssertNil(err)
|
||||
t.Assert(a1.Ids, a2.Ids)
|
||||
t.Assert(a1.Ids2, a2.Ids2)
|
||||
t.Assert(a1.Title, a2.Title)
|
||||
t.Assert(a1.Flag.String(), a2.Flag.String())
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user