database/gdb: The Insert method reports a null pointer error
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 请提供更多代码,v2.7.2 没有复现
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 请提供更多代码,v2.7.2 没有复现
PG数据库,insert方法,使用结构体作为data,结构体中其中一个字段值为nil就会报错(2.7.1版本没有这个问题)。
这个值为nil的字段,是一个在数据库中允许为NULL的字段。
涉及数据库环境,不太好提供demo。不过,我判断应该跟数据库类型没有关系。
触发panic的方法如下图:
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.