-
Notifications
You must be signed in to change notification settings - Fork 228
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
[bug] schema: converter not found for Page, when the struct name is same with field name. #195
Comments
Hi @donnol, I believe this is expected and cannot be considered as a bug because:
is equivalent to:
when you try to decode you are trying to decode a string into a struct which schema does know how to do. To work around it, you need to use the full path in your query string: |
@donnol Does my answer help ? because schema uses reflection, it's only aware of the
I hope this helps. |
{
tp := reflect.TypeOf(Outer{})
//prints 1
fmt.Println(tp.NumField())
i := 0
for i < tp.NumField() {
if tp.Field(i).Anonymous {
fmt.Println("anonymous", tp.Field(i).Type, tp.Field(i).Type.NumField())
}
fmt.Println(tp.Field(i).Name)
i++
}
} I think we can use |
I believe it should be feasible, thanks for the information. I propose adding a flag when decoding/encoding that can define the behavior of the decoder/encoder when dealing embded structs. The flag can define whether we need to unwrap the structs or just treat them as a field. We can name it for example |
@zak905 if you have time, if you'd like to open a new ticket for this as a feature request we can look at adding it. |
Sure, I can look into it ! |
Steps to Reproduce
playground
Expected behavior
Parse form to
Outer
struct successfully.The text was updated successfully, but these errors were encountered: