Skip to content
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

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open

database/gdb: fix #2119 #3559

wants to merge 5 commits into from

Conversation

wln32
Copy link
Member

@wln32 wln32 commented May 4, 2024

gstructs.Type.FieldKeys() 无法识别匿名结构体的字段,导致带有With的查询时,查询的字段不符合期望 #2119

if t.Kind() != reflect.Struct {
return []string{}
}
return getStructFields(t.Type)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里不能直接改这个基础方法,根据issue描述,似乎是这里没有获取到匿名结构体的Field。这里有一个RecursiveOption的控制你可以研究一下呢?
image

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gqcn 这里获取的是最外层结构体,
123456

所以那里是无法获取到Status结构体的字段

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里不能直接改这个基础方法,根据issue描述,似乎是这里没有获取到匿名结构体的Field。这里有一个

倒是可以使用gstructs包的其他方法来解析结构体获取所有的字段,当时我看那个方法只有这里使用了,所以就做了改动。

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gqcn 这里获取的是最外层结构体, 123456

所以那里是无法获取到Status结构体的字段

那截图红框部分没有达到预期,预期是如果内嵌的结构体在没有tag时嵌套结构体的属性会作为Fields返回。可以研究下这个方法为什么失败了呢?

if t.Kind() != reflect.Struct {
return []string{}
}
return getStructFields(t.Type)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gqcn 这里获取的是最外层结构体, 123456

所以那里是无法获取到Status结构体的字段

那截图红框部分没有达到预期,预期是如果内嵌的结构体在没有tag时嵌套结构体的属性会作为Fields返回。可以研究下这个方法为什么失败了呢?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

WithAll().Scan(&list) can't fetch embedded struct from HasOne relation's children table
2 participants