-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
database/gdb: fix #2119 #3559
base: master
Are you sure you want to change the base?
database/gdb: fix #2119 #3559
Conversation
os/gstructs/gstructs_type.go
Outdated
if t.Kind() != reflect.Struct { | ||
return []string{} | ||
} | ||
return getStructFields(t.Type) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gqcn 这里获取的是最外层结构体,
所以那里是无法获取到Status结构体的字段
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里不能直接改这个基础方法,根据
issue
描述,似乎是这里没有获取到匿名结构体的Field
。这里有一个
倒是可以使用gstructs包的其他方法来解析结构体获取所有的字段,当时我看那个方法只有这里使用了,所以就做了改动。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gqcn 这里获取的是最外层结构体,
所以那里是无法获取到Status结构体的字段
那截图红框部分没有达到预期,预期是如果内嵌的结构体在没有tag
时嵌套结构体的属性会作为Fields
返回。可以研究下这个方法为什么失败了呢?
os/gstructs/gstructs_type.go
Outdated
if t.Kind() != reflect.Struct { | ||
return []string{} | ||
} | ||
return getStructFields(t.Type) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gqcn 这里获取的是最外层结构体,
所以那里是无法获取到Status结构体的字段
那截图红框部分没有达到预期,预期是如果内嵌的结构体在没有tag
时嵌套结构体的属性会作为Fields
返回。可以研究下这个方法为什么失败了呢?
2.使用gstructs.Fields获取结构体的字段
gstructs.Type.FieldKeys() 无法识别匿名结构体的字段,导致带有With的查询时,查询的字段不符合期望 #2119