fix(binding): fix default tag overriding JSON values in anonymous struct#1461
Closed
FlameMida wants to merge 6 commits intocloudwego:developfrom
Closed
fix(binding): fix default tag overriding JSON values in anonymous struct#1461FlameMida wants to merge 6 commits intocloudwego:developfrom
FlameMida wants to merge 6 commits intocloudwego:developfrom
Conversation
Fixed two issues:
1. Anonymous embedded struct fields had incorrect JSONName (e.g., "PageInfo.page"
instead of "page"), causing keyExist() to fail
2. Default values from form/query tags were overriding JSON-provided values
Solution:
- Skip JSONName update for anonymous fields to match Go's JSON flattening behavior
- Add defaultDisabled flag to prevent default value override in single loop pass
Test: Added TestBind_AnonymousFieldWithDefaultTag covering 4 scenarios including
nested anonymous structs
Contributor
|
has fixed #1480 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What type of PR is this?
fix: fix default tag overriding JSON values in anonymous struct
Check the PR title.
(Optional) Translate the PR title into Chinese.
(Optional) More detailed description for this PR(en: English/zh: Chinese).
en:
zh(optional):
(Optional) Which issue(s) this PR fixes:
Fixes #1454
(Optional) The PR that updates user documentation: