You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Breaking Change on v4.12.0 When Binding to map[string]interface{} -> the field become list #2652
changed the title [-]Breaking Change on v4.12.0 When Binding to map[string]interface{}[/-][+]Breaking Change on v4.12.0 When Binding to map[string]interface{} -> the field become list[/+]on Jun 27, 2024
@slzhffktm I've submitted a pull request (#2656) that addresses this issue by maintaining backwards compatibility for map[string]interface{} binding while supporting the new functionality.
The PR modifies the bindData function to:
Store single values as strings
Store multiple values as []string
However, if the maintainers decide not to merge this change, here's an alternative solution you can use in your code to achieve the same result:
You can use this helper function with new version without breaking code regardless of whether the PR is merged. It processes the map[string]interface{} returned by c.Bind() and converts any []string values to single strings if they contain only one element.
I stumbled over this issue because I have the same problem after updating to 4.12.
I'm wondering when this fix will be released, so until now I'm relying on this helper function.
Activity
[-]Breaking Change on v4.12.0 When Binding to map[string]interface{}[/-][+]Breaking Change on v4.12.0 When Binding to map[string]interface{} -> the field become list[/+]thesaltree commentedon Jul 9, 2024
@slzhffktm I've submitted a pull request (#2656) that addresses this issue by maintaining backwards compatibility for
map[string]interface{}binding while supporting the new functionality.The PR modifies the
bindDatafunction to:[]stringHowever, if the maintainers decide not to merge this change, here's an alternative solution you can use in your code to achieve the same result:
You can use this helper function with new version without breaking code regardless of whether the PR is merged. It processes the
map[string]interface{}returned byc.Bind()and converts any[]stringvalues to single strings if they contain only one element.nicandcranny commentedon Sep 9, 2024
Hello @thesaltree ! Seems like your PR is merged, thank you for your contribution!!
arigon commentedon Nov 7, 2024
Your return header is not necessary because map types are reference types:
I stumbled over this issue because I have the same problem after updating to 4.12.
I'm wondering when this fix will be released, so until now I'm relying on this helper function.