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(contrib/drivers/pgsql): fix insert error when data struct field has nil in PgSQL #3679

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

oldme-git
Copy link
Member

Fixes #3668

var (
fieldValueKind = reflect.TypeOf(fieldValue).Kind()
)
if fieldValue == nil {
Copy link
Member

Choose a reason for hiding this comment

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

是否这里使用empty.IsNil来判断更合适一些呢?

Copy link
Member Author

Choose a reason for hiding this comment

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

用不了,empty 是内部包

Copy link
Member

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来判断。

Copy link
Member Author

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 {
Copy link
Member

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来判断。

@oldme-git oldme-git requested a review from gqcn July 29, 2024 02:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

database/gdb: The Insert method reports a null pointer error
2 participants