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

fix: customized type decode for binding #965

Merged
merged 1 commit into from
Oct 9, 2023

Conversation

FGYFFFF
Copy link
Contributor

@FGYFFFF FGYFFFF commented Sep 27, 2023

What type of PR is this?

fix

Check the PR title.

  • This PR title match the format: <type>(optional scope): <description>
  • The description of this PR title is user-oriented and clear enough for others to understand.
  • Attach the PR updating the user documentation if the current PR requires user awareness at the usage level. User docs repo

(Optional) Translate the PR title into Chinese.

修复自定义绑定函数带来的 time.Time 绑定不一致的行为

(Optional) More detailed description for this PR(en: English/zh: Chinese).

en: Fix inconsistent behavior of time.Time bindings due to custom binding functions
zh(optional): 修复自定义绑定函数带来的 time.Time 绑定不一致的行为
之前的绑定行为是必须有对应的 tag 才会去执行,自定义校验函数,例如下方结构体,只有请求的 query 有 "A" 的时候才会去执行自定义绑定函数。

type A struct {
     A  time.Time `query:"A"`
}

重构后,修改了这一行为,认为 "只要定义了自定义绑定函数就一定会执行,并且会将请求内容传给用户,让其自行取值",所以自带的 time.Time 的自定义方法会将用户 json 已经解析过的 time.Time 覆盖掉。
这块还是改回只有 tag 存在才执行自定义方法,避免出现其他覆盖的行为

(Optional) Which issue(s) this PR fixes:

#964

(Optional) The PR that updates user documentation:

@FGYFFFF FGYFFFF requested review from a team as code owners September 27, 2023 08:48
@FGYFFFF FGYFFFF force-pushed the fix/customized_type_decode branch from 97e6e7c to be81d50 Compare September 27, 2023 08:56
@FGYFFFF FGYFFFF force-pushed the fix/customized_type_decode branch from be81d50 to da33d15 Compare September 27, 2023 09:06
@codecov
Copy link

codecov bot commented Sep 27, 2023

Codecov Report

All modified lines are covered by tests ✅

Comparison is base (18af58f) 81.87% compared to head (09b5509) 81.85%.
Report is 1 commits behind head on develop.

❗ Current head 09b5509 differs from pull request most recent head da33d15. Consider uploading reports for the commit da33d15 to get more accurate results

Additional details and impacted files
@@             Coverage Diff             @@
##           develop     #965      +/-   ##
===========================================
- Coverage    81.87%   81.85%   -0.03%     
===========================================
  Files           98       98              
  Lines         9926     9926              
===========================================
- Hits          8127     8125       -2     
- Misses        1310     1311       +1     
- Partials       489      490       +1     

see 1 file with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@welkeyever welkeyever left a comment

Choose a reason for hiding this comment

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

LGTM

@welkeyever welkeyever merged commit c0512ff into cloudwego:develop Oct 9, 2023
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants