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

database/gdb: The Insert method reports a null pointer error #3668

Open
alaywn opened this issue Jun 28, 2024 · 4 comments · May be fixed by #3679
Open

database/gdb: The Insert method reports a null pointer error #3668

alaywn opened this issue Jun 28, 2024 · 4 comments · May be fixed by #3679
Labels
bug It is confirmed a bug, but don't worry, we'll handle it.

Comments

@alaywn
Copy link
Contributor

alaywn commented Jun 28, 2024

Go version

go version go1.22.4 darwin/arm64

GoFrame version

2.7.2

Can this bug be reproduced with the latest release?

Option Yes

What did you do?

对项目原有代码没有做任何修改

What did you see happen?

someDAO.Ctx(ctx).
Cache(gdb.CacheOption{
Duration: -1,
Name: "cache_name",
Force: false,
}).
Data(some_struct_data).
Insert()

执行类似上述的Insert代码时,提示空指针错误。在2.7.1版本中上述代码是正常的,没有任何问题。

What did you expect to see?

修复bug

@alaywn alaywn added the bug It is confirmed a bug, but don't worry, we'll handle it. label Jun 28, 2024
@oldme-git
Copy link
Member

@alaywn 请提供更多代码,v2.7.2 没有复现

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


@alaywn Please provide more code, v2.7.2 does not reproduce

@alaywn
Copy link
Contributor Author

alaywn commented Jul 7, 2024

@alaywn 请提供更多代码,v2.7.2 没有复现

PG数据库,insert方法,使用结构体作为data,结构体中其中一个字段值为nil就会报错(2.7.1版本没有这个问题)。

这个值为nil的字段,是一个在数据库中允许为NULL的字段。

涉及数据库环境,不太好提供demo。不过,我判断应该跟数据库类型没有关系。

触发panic的方法如下图:

image

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


@alaywn Please provide more code, v2.7.2 does not reproduce

In the PG database, the insert method uses a structure as data. If one of the fields in the structure is nil, an error will be reported (version 2.7.1 does not have this problem).

This field with a value of nil is a field that is allowed to be NULL in the database.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug It is confirmed a bug, but don't worry, we'll handle it.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants