-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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(contrib/drivers/pgsql): fix insert error when data struct field has nil in PgSQL #3679
base: master
Are you sure you want to change the base?
Conversation
var ( | ||
fieldValueKind = reflect.TypeOf(fieldValue).Kind() | ||
) | ||
if fieldValue == nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
是否这里使用empty.IsNil
来判断更合适一些呢?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
用不了,empty 是内部包
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
在golang
里面的interface{}
判断为== nil
会有坑,因为它在内部需要判断类型和值,类型不相同时判断会失效,所以这里需要使用框架封装的IsNil
方法来判断避免踩坑。这里可以使用g.IsNil
来判断。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
var ( | ||
fieldValueKind = reflect.TypeOf(fieldValue).Kind() | ||
) | ||
if fieldValue == nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
在golang
里面的interface{}
判断为== nil
会有坑,因为它在内部需要判断类型和值,类型不相同时判断会失效,所以这里需要使用框架封装的IsNil
方法来判断避免踩坑。这里可以使用g.IsNil
来判断。
Fixes #3668